MVVM:在UWP中使用自定义字体和XAML
问题描述:
我试图在UWP应用程序中使用weather-icons的图标字体。MVVM:在UWP中使用自定义字体和XAML
在我的XAML我有类似
<Grid.Resources>
<FontFamily x:Key="WeatherFonts">/Assets/Fonts/weathericons-regular-webfont.ttf#Weather Icons</FontFamily>
</Grid.Resources>
<TextBlock x:Name="tbFontAwesome"
Text="{Binding CurrentWeather.Icon}"
FontFamily="{StaticResource WeatherFonts}"
Foreground="White"
FontSize="72"/>
在我视图模型我设置
CurrentWeather.Icon = ""
如果我只是硬编码这在XAML,它工作正常。
<TextBlock x:Name="tbFontAwesome"
Text=""
FontFamily="{StaticResource WeatherFonts}"
Foreground="White"
FontSize="72"/>
当我使用硬编码的XAML,图标显示出来就好了,但如果我尝试做绑定到字符串时,TextBlock
只是显示了字符串,而不是图标。
答
尝试System.Net.WebUtility.HtmlDecode("")
。
这工作。我遇到了麻烦,但事实证明还有另一个问题。感谢帮助的人。 –
@MatthewTheTerrible nws。很高兴听到你解决它! –