Freigeben über


How to: Use System Parameters Keys

System resources expose a number of system metrics as resources to help developers create visuals that are consistent with system settings. SystemParameters is a class that contains both system parameter values and resource keys that bind to the values—for example, FullPrimaryScreenHeight and FullPrimaryScreenHeightKey. System parameter metrics can be used as either static or dynamic resources. Use a dynamic resource if you want the parameter 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 parameter dynamic resources to style or customize a button. This XAML example sizes a button by assigning SystemParameters values to the button's width and height.

Example

<Style x:Key="SimpleParam" TargetType="{x:Type Button}">
    <Setter Property = "Height" Value= "{DynamicResource {x:Static SystemParameters.CaptionHeightKey}}"/>
    <Setter Property = "Width" Value= "{DynamicResource {x:Static SystemParameters.IconGridWidthKey}}"/>
</Style>

See Also

Tasks

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