代码改变世界

SystemFonts Class的典型用法?

2007-02-05 09:44  爱车龟速兔  阅读(295)  评论(0编辑  收藏  举报

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>

这段代码对应的C#代码是:

Button btncsharp = new Button();

btncsharp.Content = "SystemFonts";

btncsharp.Background = SystemColors.ControlDarkDarkBrush;

btncsharp.FontSize = SystemFonts.IconFontSize;

btncsharp.FontWeight = SystemFonts.MessageFontWeight;

btncsharp.FontFamily = SystemFonts.CaptionFontFamily;

cv1.Children.Add(btncsharp);

 

This example shows how to use the static resources of SystemFonts in order to style or customize a button.

这个例子演示了如何使用SystemFonts的静态资源去定制一个button.

SystemFonts is a class that contains both system font values and resources that bind to the values, for example, CaptionFontFamily is a SystemFonts value and CaptionFontFamilyKey is a corresponding resource key.

SystemFonts类是一个既包含系统字体值又包含绑定到系统字体值的系统字体资源. 例如CaptionFontFamily是一个SystemFonts的值, CaptionFontFamilyKey是一个SystemFonts的资源关键字.