Using a custom font in WPF

A quick tip on how to use custom fonts in a WPF application.

<Window.Resources>
   
<Style x:Key="MyCustomFont">
       
<Setter Property="TextElement.FontFamily" Value="fonts/#Arial Narrow Bold"/>
        </Style>
   
</Window.Resources>

. . .

. . .

<TextBlock  Style="{DynamicResource MyCustomFont}">Font Demo</TextBlock>

That's it. It's real easy!
Ebook Download
View all
Learn
View all