在wpf中添加图标字体 [英] Add Icon font in wpf
本文介绍了在wpf中添加图标字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在WPF中添加自定义图标.我使用entypo
和Font-Awesome
.
I want to add custom icon in WPF. I use entypo
and Font-Awesome
.
我将此包装添加到解决方案中,并在XAML中使用它.
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="" Style="{DynamicResource FontAwesome}" />
但是不要显示图标.
推荐答案
确保将字体添加为资源.然后,使用以下字符串:
Make sure your font is added as a resource. Then, use the following string:
<Setter Property="TextElement.FontFamily" Value="pack://application:,,,/fonts/#FontAwesome" />
在上面的字符串中,我假设字体的名称(不是字体的文件名)是FontAwesome.
In the string above, I'm assuming that the font's name (not the font's filename) is FontAwesome.
这篇关于在wpf中添加图标字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文