Files
docs-desktop/dotnet-desktop-guide/framework/wpf/advanced/how-to-use-systemparameters.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

3.1 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Use SystemParameters 03/30/2017
csharp
vb
classes [WPF], SystemParameters
02e7a5de-94eb-4953-b91c-52e6c872ad5b

How to: Use SystemParameters

This example shows how to access and use the properties of xref:System.Windows.SystemParameters in order to style or customize a button.

Example

System resources expose several system based settings as resources in order to help you create visuals that are consistent with system settings. xref:System.Windows.SystemParameters is a class that contains both system parameter value properties, and resource keys that bind to the values. For example, xref:System.Windows.SystemParameters.FullPrimaryScreenHeight%2A is a xref:System.Windows.SystemParameters property value and xref:System.Windows.SystemParameters.FullPrimaryScreenHeightKey%2A is the corresponding resource key.

In [!INCLUDETLA2#tla_xaml], you can use the members of xref:System.Windows.SystemParameters as either a static property usage, or a dynamic resource references (with the static property value as the key). Use a dynamic resource reference if you want the system based value to update automatically while the application runs; otherwise, use a static reference. Resource keys have the suffix Key appended to the property name.

The following example shows how to access and use the static values of xref:System.Windows.SystemParameters to style or customize a button. This markup example sizes a button by applying xref:System.Windows.SystemParameters values to a button.

[!code-xamlSystemRes_snip#ParameterStaticResources]

To use the values of xref:System.Windows.SystemParameters in code, you do not have to use either static references or dynamic resource references. Instead, use the values of the xref:System.Windows.SystemParameters class. Although the non-key properties are apparently defined as static properties, the runtime behavior of [!INCLUDETLA2#tla_winclient] as hosted by the system will reevaluate the properties in realtime, and will properly account for user-driven changes to system values. The following example shows how to set the width and height of a button by using xref:System.Windows.SystemParameters values.

[!code-csharpSystemRes_snip#ParameterResourcesCode] [!code-vbSystemRes_snip#ParameterResourcesCode]

See also