Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making text wrap on Add Widget dialog #3009

Merged
merged 8 commits into from
May 31, 2024
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions tools/Dashboard/DevHome.Dashboard/Views/AddWidgetDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private async Task FillAvailableWidgetsAsync()
{
IsExpanded = true,
Tag = providerDef,
Content = providerDef.DisplayName,
Content = new TextBlock { Text = providerDef.DisplayName, TextWrapping = TextWrapping.Wrap },
};

navItem.SetValue(ToolTipService.ToolTipProperty, providerDef.DisplayName);
Expand Down Expand Up @@ -148,17 +148,21 @@ private async Task FillAvailableWidgetsAsync()
}
}

private async Task<StackPanel> BuildWidgetNavItem(ComSafeWidgetDefinition widgetDefinition)
private async Task<Grid> BuildWidgetNavItem(ComSafeWidgetDefinition widgetDefinition)
{
var image = await _widgetIconService.GetIconFromCacheAsync(widgetDefinition, ActualTheme);
return BuildNavItem(image, widgetDefinition.DisplayTitle);
}

private StackPanel BuildNavItem(BitmapImage image, string text)
private Grid BuildNavItem(BitmapImage image, string text)
{
var itemContent = new StackPanel
var itemContent = new Grid
{
Orientation = Orientation.Horizontal,
ColumnDefinitions =
{
new ColumnDefinition { Width = GridLength.Auto },
new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
},
};

if (image is not null)
Expand All @@ -167,21 +171,26 @@ private StackPanel BuildNavItem(BitmapImage image, string text)
{
Width = 16,
Height = 16,
Margin = new Thickness(0, 0, 10, 0),
Margin = new Thickness(0, 0, 9, 0),
guimafelipe marked this conversation as resolved.
Show resolved Hide resolved
Fill = new ImageBrush
{
ImageSource = image,
Stretch = Stretch.Uniform,
},
};
Grid.SetColumn(itemSquare, 0);

itemContent.Children.Add(itemSquare);
}

var itemText = new TextBlock()
{
Text = text,
TextWrapping = TextWrapping.Wrap,
VerticalAlignment = VerticalAlignment.Center,
};
Grid.SetColumn(itemText, 1);

itemContent.Children.Add(itemText);

return itemContent;
Expand Down
Loading