wpf 引用ttf viewmodel绑定
引用字体
<UserControl.Resources>
<!-- 方式一 -->
<FontFamily x:Key="IconFont">
Pack://application:,,,/MyApp;component/font/#fontname
</FontFamily>
<!-- 方式二 -->
<FontFamily x:Key="iconFontTest">/Test.Server;Component/src/#iconfont</FontFamily>
</UserControl.Resources>
viewmodel
使用
如果在viewmodel中或后台代码中使用,直接使用xe692即可(移除开头的&#,换成\,然后将结尾的;移除)
也可以通过System.Net.WebUtility.HtmlDecode("")解码就可以在viewmodel中使用
前台直接绑定
txt.Text = "\xe621";
控件绑定字体
FontFamily="{StaticResource IconFont}"
留待后查,同时方便他人
联系我:renhanlinbsl@163.com
联系我:renhanlinbsl@163.com