Sometimes we need to give options to users to select a font family to use with their own methods for implementation.
Let’s see the steps.
Create a new Windows 10 universal application and go to your MainPage.xaml.
Now add one listview control to list the font family and also add one control inside the ListView, for font name like the following xaml code. Add one textblock control to see the changes.
- <TextBlock x:Name="sampleTextBloxk" Text="Suresh M C# Corner MVP">
- </TextBlock>
- <ListView x:Name="FontListBox" SelectionChanged="FontListBox_SelectionChanged">
- <ListView.ItemTemplate>
- <DataTemplate>
- <TextBlock Text="{Binding fName}"></TextBlock>
- </DataTemplate>
- </ListView.ItemTemplate>
- </ListView>

- public void getFontList()
- {
- List < fonts > fList = newList < fonts > ();
- string[] fontList = Microsoft.Graphics.Canvas.Text.CanvasTextFormat.GetSystemFontFamilies();
- foreach(var font in fontList)
- {
- fList.Add(newfonts()
- {
- fName = string.Format("Font: {0}", font)
- });
- }
- FontListBox.ItemsSource = fList;
- }
- private void FontListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- var selectedFont= e.AddedItems[0].ToString();
- sampleTextBloxk.FontFamily = newFontFamily(selectedFont);
- }
- Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
- localSettings.Values["Myfonts"] = selectedFont;
- object value = localSettings.Values["Myfonts"];

For more information on Windows 10 UWP, refer to my e-book:


Sonu ChaudharyPosted Jun 6, 2016, 6:00 AM EDT
good one...
Debasis SahaTOP 100Posted Jun 5, 2016, 8:25 PM EDT
Good One..
Vignesh ManiTOP 100Posted Jun 2, 2016, 1:58 AM EDT
Nice
Ketak BhalsingPosted Jun 1, 2016, 8:44 PM EDT
Helpful information....
Thiruppathi RPosted Jun 1, 2016, 6:22 PM EDT
Nice...
Debasis SahaTOP 100Posted Jun 1, 2016, 10:09 AM EDT
Nice one..