1 添加字体文件到项目
image.png
image.png
2 在需要更改字体的界面添加代码
<Window x:Class="Controls.EmbeddedFont"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="EmbeddedFont" Height="300" Width="300">
<Grid>
<Label FontSize="20" FontFamily="./#bayern">This is an embedded font</Label>
</Grid>
</Window>
关键代码为:
FontFamily="./#bayern"
运行结果:
image.png