
比如需要有這種電子表的字體風格--這種樣式叫 :longzhoufeng 字體 在微軟的字體有 Quartz MS.TTF或者Quartz Regular.TTF字體。下面以Quartz Regular.TTF為例
找到 Quartz Regular.TTF字體文件,把它添加到WPF工程的Resources內,並設置成Resource類型。
寫一個FontStyle.xaml 的 字體資源
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="Quartz Regular">
<Setter Property="TextElement.FontFamily" Value="/Resources/#Quartz Regular"/>
</Style></ResourceDictionary>
字體使用中將字體作為字體樣式來引用
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/FontStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources> <Grid Background="#2a3747">
<Label Content="5201314" HorizontalAlignment="Left" FontSize="34"
VerticalContentAlignment="Center" Height="60" Margin="101,77,0,0" VerticalAlignment="Top"
Width="286" Foreground="GreenYellow" Style="{DynamicResource 'Quartz Regular'}" />
<Label Content="lovessea@sina.com" HorizontalAlignment="right" Foreground="White" Height="29" Margin="379,291,0,0"
VerticalAlignment="Top" Width="128"/>
</Grid>
http://www.th7.cn/Program/WPF/201506/489768.shtml
