Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Icon font in wpf

Tags:

wpf

font-face

I want to add custom icon in WPF. I use entypo and Font-Awesome.

I add this pakage in solution and use it in XAML.

<UserControl.Resources>
    <Style x:Key="FontAwesome">
        <Setter Property="TextElement.FontFamily" Value="fonts/FontAwesome.ttf" />
    </Style>
</UserControl.Resources>


<TextBlock Text="&#xf01a;" Style="{DynamicResource FontAwesome}" />

But don't show Icon.

like image 759
Niloo Avatar asked Jan 27 '14 06:01

Niloo


1 Answers

Make sure your font is added as a resource. Then, use the following string:

<Setter Property="TextElement.FontFamily" Value="pack://application:,,,/fonts/#FontAwesome" />

In the string above, I'm assuming that the font's name (not the font's filename) is FontAwesome.

like image 50
K Mehta Avatar answered Nov 08 '22 07:11

K Mehta