Skip to content

Commit 2e23d76

Browse files
authored
Include Symbol enum indication in Iconography page (#1881)
## Description - Fixes #1880 ## Screenshots (if appropriate): ![image](https://github.com/user-attachments/assets/53fb082e-81f2-4746-8117-1f634cc19721) ![image](https://github.com/user-attachments/assets/9cbfb85f-af25-4569-9ae2-47e51647c73c) ![image](https://github.com/user-attachments/assets/d2ff205a-0573-4b5f-893c-ea10af4b33a1) ![image](https://github.com/user-attachments/assets/2f4afc99-0e9b-4cc9-aac1-ae4412f18ba4) ![image](https://github.com/user-attachments/assets/d0a7e3a5-222e-4393-93ea-f78ee7861533) ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [x] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality)
1 parent 0b352d6 commit 2e23d76

File tree

4 files changed

+45
-21
lines changed

4 files changed

+45
-21
lines changed

WinUIGallery/Models/IconData.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Microsoft.UI.Xaml.Controls;
12
using System;
23
using System.Collections.Generic;
34
using System.Text.Json.Serialization;
@@ -13,6 +14,8 @@ public class IconData
1314
public string Character => char.ConvertFromUtf32(Convert.ToInt32(Code, 16));
1415
public string CodeGlyph => "\\u" + Code;
1516
public string TextGlyph => "&#x" + Code + ";";
17+
18+
public string SymbolName => Enum.TryParse<Symbol>(Name, out var symbol) ? symbol.ToString() : null;
1619
}
1720
[JsonSourceGenerationOptions(PropertyNameCaseInsensitive = true)]
1821
[JsonSerializable(typeof(List<IconData>))]

WinUIGallery/Pages/ItemPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
Style="{ThemeResource BodyTextBlockStyle}"
5858
Text="{x:Bind Item.Description}"
5959
Visibility="{x:Bind Item.Description, Converter={StaticResource stringVisibilityConverter}}" />
60-
<Frame x:Name="contentFrame" Grid.Row="2" />
60+
<Frame x:Name="contentFrame" Grid.Row="1" />
6161
</Grid>
6262
</ScrollViewer>
6363

WinUIGallery/Samples/ControlPages/Design/IconographyPage.xaml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!--
1+
<!--
22
//*********************************************************
33
//
44
// Copyright (c) Microsoft. All rights reserved.
@@ -88,16 +88,14 @@
8888
NotEmptyValue="False" />
8989
</Page.Resources>
9090

91-
<Grid HorizontalAlignment="Stretch" RowSpacing="8">
91+
<Grid RowSpacing="8">
9292
<Grid.RowDefinitions>
93-
<RowDefinition Height="Auto" />
9493
<RowDefinition Height="Auto" />
9594
<RowDefinition Height="Auto" />
9695
<RowDefinition Height="*" />
9796
</Grid.RowDefinitions>
9897

9998
<toolkit:SettingsExpander
100-
Grid.Row="1"
10199
AutomationProperties.AccessibilityView="Raw"
102100
Header="How to use Segoe Fluent Icons"
103101
IsExpanded="False">
@@ -143,7 +141,7 @@
143141
</toolkit:SettingsExpander>
144142

145143
<StackPanel
146-
Grid.Row="2"
144+
Grid.Row="1"
147145
Margin="0,24,0,0"
148146
Spacing="8">
149147
<TextBlock Style="{ThemeResource BodyStrongTextBlockStyle}" Text="Fluent Icons Library" />
@@ -158,19 +156,17 @@
158156
</StackPanel>
159157

160158
<controls:SampleThemeListener
161-
Grid.Row="3"
162-
VerticalAlignment="Top"
159+
Grid.Row="2"
163160
IsTabStop="True">
164161
<Grid Style="{ThemeResource GalleryTileGridStyle}">
165162
<Grid.ColumnDefinitions>
166163
<ColumnDefinition Width="*" />
167-
<ColumnDefinition Width="316" />
164+
<ColumnDefinition Width="334" />
168165
</Grid.ColumnDefinitions>
169166
<ItemsView
170167
x:Name="IconsItemsView"
171168
MinWidth="100"
172169
Padding="16"
173-
HorizontalAlignment="Stretch"
174170
ItemTemplate="{StaticResource IconTemplate}"
175171
SelectionChanged="IconsItemsView_SelectionChanged"
176172
TabFocusNavigation="Once">
@@ -223,13 +219,25 @@
223219
<TextBlock
224220
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
225221
Style="{StaticResource CaptionTextBlockStyle}"
226-
Text="XAML" />
227-
<controls:SampleCodePresenter x:Name="XAMLCodePresenter" Style="{StaticResource CodeValuePresenterStyle}" />
222+
Text="FontIcon XAML" />
223+
<controls:SampleCodePresenter x:Name="XAMLCodePresenterFont" Style="{StaticResource CodeValuePresenterStyle}" />
224+
<TextBlock
225+
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
226+
Style="{StaticResource CaptionTextBlockStyle}"
227+
Text="FontIcon C#" />
228+
<controls:SampleCodePresenter x:Name="CSharpCodePresenterFont" Style="{StaticResource CodeValuePresenterStyle}" />
229+
<TextBlock
230+
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
231+
Style="{StaticResource CaptionTextBlockStyle}"
232+
Text="SymbolIcon XAML"
233+
Visibility="{Binding SelectedItem.SymbolName, Converter={StaticResource nullToVisibilityConverter}, Mode=OneWay}"/>
234+
<controls:SampleCodePresenter x:Name="XAMLCodePresenterSymbol" Style="{StaticResource CodeValuePresenterStyle}" />
228235
<TextBlock
229236
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
230237
Style="{StaticResource CaptionTextBlockStyle}"
231-
Text="C#" />
232-
<controls:SampleCodePresenter x:Name="CSharpCodePresenter" Style="{StaticResource CodeValuePresenterStyle}" />
238+
Text="SymbolIcon C#"
239+
Visibility="{Binding SelectedItem.SymbolName, Converter={StaticResource nullToVisibilityConverter}, Mode=OneWay}"/>
240+
<controls:SampleCodePresenter x:Name="CSharpCodePresenterSymbol" Style="{StaticResource CodeValuePresenterStyle}" />
233241
<TextBlock
234242
Margin="0,4,0,0"
235243
Foreground="{ThemeResource TextFillColorSecondaryBrush}"

WinUIGallery/Samples/ControlPages/Design/IconographyPage.xaml.cs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
//
99
//*********************************************************
1010

11+
using CommunityToolkit.WinUI.Controls;
12+
using Microsoft.UI.Xaml;
13+
using Microsoft.UI.Xaml.Controls;
1114
using System;
1215
using System.Collections.Generic;
1316
using System.Linq;
17+
using System.Threading;
1418
using System.Threading.Tasks;
1519
using WinUIGallery.Helpers;
16-
using Microsoft.UI.Xaml;
17-
using Microsoft.UI.Xaml.Controls;
18-
using System.Threading;
19-
using CommunityToolkit.WinUI.Controls;
2020
using WinUIGallery.Models;
2121

2222
namespace WinUIGallery.ControlPages;
@@ -70,9 +70,22 @@ private void IconsItemsView_Loaded(object sender, RoutedEventArgs e)
7070
}
7171
private void SetSampleCodePresenterCode(IconData value)
7272
{
73-
XAMLCodePresenter.Code = $"<FontIcon Glyph=\"{value.TextGlyph}\" />";
73+
XAMLCodePresenterFont.Code = $"<FontIcon Glyph=\"{value.TextGlyph}\" />";
7474

75-
CSharpCodePresenter.Code = $"FontIcon icon = new FontIcon();" + Environment.NewLine + "icon.Glyph = \"" + value.CodeGlyph + "\";";
75+
CSharpCodePresenterFont.Code = "FontIcon icon = new FontIcon();" + Environment.NewLine + $"icon.Glyph = \"{value.CodeGlyph}\";";
76+
77+
if (value.SymbolName != null)
78+
{
79+
XAMLCodePresenterSymbol.Code = $"<SymbolIcon Symbol=\"{value.SymbolName}\" />";
80+
81+
CSharpCodePresenterSymbol.Code = "SymbolIcon icon = new SymbolIcon();" + Environment.NewLine + $"icon.Symbol = Symbol.{value.SymbolName};";
82+
}
83+
else
84+
{
85+
XAMLCodePresenterSymbol.Code = null;
86+
87+
CSharpCodePresenterSymbol.Code = null;
88+
}
7689
}
7790

7891
private void SearchTextBox_TextChanged(object sender, AutoSuggestBoxTextChangedEventArgs args)
@@ -160,4 +173,4 @@ private void TagsItemsView_ItemInvoked(ItemsView sender, ItemsViewItemInvokedEve
160173
IconsAutoSuggestBox.Text = tag;
161174
}
162175
}
163-
}
176+
}

0 commit comments

Comments
 (0)