在 WPF 中,有两个与焦点有关的主要概念:键盘焦点和逻辑焦点。WPF ,资源,可以通过一种简单的方法来重用通常定义的对象和值。
这样可以绕过严格的资源引用创建顺序,但应注意这种 DynamicResource 技术会对性能产生一定的负面影响
Style TargetType=“TextBlock” x:Key=“Label”>
<Style TargetType="Button" x:Key="GelButton" >
<Setter Property="Margin" Value="1,2,1,2"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="Template">
<Setter.Value>
......
</Setter.Value>
</Setter>
</Style>
SystemFonts:
<Button Margin="10, 10, 5, 5" Grid.Column="0" Grid.Row="3"
FontSize="{x:Static SystemFonts.IconFontSize}"
FontWeight="{x:Static SystemFonts.MessageFontWeight}"
FontFamily="{x:Static SystemFonts.CaptionFontFamily}">
SystemFonts
</Button>
系统资源将许多系统度量作为资源公开,以帮助开发人员创建与系统设置一致的可视元素。SystemFonts 是一个类,它包含系 统字体值以及绑定到这些值的系统字体资源。例如,CaptionFontFamily 和 CaptionFontFamilyKey。