Joh*_*orf 15 wpf fonts embedded-resource
我正在尝试在我的应用程序中添加自定义字体作为资源.我在应用程序中有一个"CustomFont"目录,其中的所有字体都设置为"Resource"
<Window.Resources>
<Style x:Key="Gotham-XLight">
<Setter Property="TextElement.FontFamily"
Value="/CustomFonts;Component/#Gotham-XLight" />
</Style>
</Window.Resources>
Run Code Online (Sandbox Code Playgroud)
然后在我的TextBlock上我有这个:(在网格内)
<TextBlock x:Name="TimeTextBlock" Style="{DynamicResource Gotham-XLight}"
TextAlignment="Center" FontSize="25" FontWeight="Bold"
Foreground="White" Text="TextBlockTimer"
Margin="105,242.974,0,226.975" HorizontalAlignment="Left"
Width="221.919" />
Run Code Online (Sandbox Code Playgroud)
但是我没有像人们说的那样看到我的字体.难道我做错了什么?
试试这个
<Window.Resources>
<Style x:Key="Gotham-XLight">
<Setter Property="TextElement.FontFamily" Value="CustomFonts/#Gotham-XLight" />
</Style>
</Window.Resources>
Run Code Online (Sandbox Code Playgroud)
此外,如果您不打算在运行时更改样式,{StaticResource Gotham-XLight}那么性能会更高.
| 归档时间: |
|
| 查看次数: |
19379 次 |
| 最近记录: |