Reputation: 306
I have file 'resource.xaml' for all the styles. But I need to add a new font file to my project and re-use it instead of default font. How can I add a new font and use it? I searched the internet and see some methods. but nothing worked for me.
Thanks in Advance.
Upvotes: 0
Views: 894
Reputation: 9944
when using a custom font you must respect the following syntax:
"/FontPath/FontFileName.ttf#FontName"
for exemple :
<Setter Property="FontFamily" Value="/Fonts/VLADIMIR.TTF#Vladimir Script"/>
where the name of this font is "Vladimir Script".
Upvotes: 2
Reputation: 9723
I've had this problem before, and here's how I did it:
In App.xaml, or a resource dictionary, add the following code:
pack://application:,,,/Path/To/Font/#Name Of Font
Then, you can reference the font resource in your XAML code:
<TextBlock FontFamily="{DynamicResource NameOfResource}" Text="Hello World"/>
Upvotes: 0