#815 – Filling a ListBox with a List of All Fonts

The static Fonts.SystemFontFamilies property contains list of all fonts installed on your system.  Each element in the collection referenced by this property is a FontFamily object.

You can build a list of all fonts by binding a ListBox to this collection.  The example below uses a CollectionViewSource element, bound to SystemFontFamilies, which allows us to sort the items in the collection.  We then bind the ListBox to this collection.

        Width="300" Height="200"
        Title="Display a List of Fonts">

        <CollectionViewSource x:Key="allFonts"
                              Source="{Binding Source={x:Static Fonts.SystemFontFamilies}}">
                <scm:SortDescription PropertyName="Source"/>

        <ListBox ItemsSource="{Binding Source={StaticResource allFonts}}"
                 Margin="5" ScrollViewer.VerticalScrollBarVisibility="Auto">
                    <TextBlock Text="{Binding}"

We display each item in the list using the appropriate font by using a data template and setting the FontFamily property of a TextBlock.



About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

5 Responses to #815 – Filling a ListBox with a List of All Fonts

  1. Valdimar Thor says:

    Hi Sean, really nice blog you have with good info, tips and tricks for WPF.
    Is there no way to extract all your Tips into a file for better reading, as it’s kind a hard scolling all the way down to #1?

    • Sean says:

      Good question–and a sensible request. I’m hoping to collate everything into a Word doc or PDF and then post it. I’ll look into this and have something soon.

  2. Markiyan says:

    What if WPF can’t draw a font and it crashes an application? How to check it?

  3. bindya says:


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: