Share via


How to: Use System Fonts Keys

System resources expose a number of system metrics as resources to help developers create visuals that are consistent with system settings. SystemFonts is a class that contains both system font values and system font resources that bind to the values—for example, CaptionFontFamily and CaptionFontFamilyKey.

System font metrics can be used as either static or dynamic resources. Use a dynamic resource if you want the font metric to update automatically while the application runs; otherwise use a static resource.

NoteNote:

Dynamic resources have the keyword Key appended to the property name.

The following example shows how to access and use system font dynamic resources to style or customize a button. This XAML example creates a button style that assigns SystemFonts values to a button.

Example

<Style x:Key="SimpleFont" TargetType="{x:Type Button}">
    <Setter Property = "FontSize" Value= "{DynamicResource {x:Static SystemFonts.IconFontSizeKey}}"/>
    <Setter Property = "FontWeight" Value= "{DynamicResource {x:Static SystemFonts.MessageFontWeightKey}}"/>
    <Setter Property = "FontFamily" Value= "{DynamicResource {x:Static SystemFonts.CaptionFontFamilyKey}}"/>
</Style>

See Also

Tasks

How to: Paint an Area with a System Brush
How to: Use SystemParameters
How to: Use SystemFonts