O'Reilly logo

XAML Unleashed by Adam Nathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Referencing Static Fields and Properties

In WPF apps, but not the other types of apps, you can reference static fields and properties with the x:Static keyword. For example, the following Button’s Height is assigned to the value of the SystemParameters.IconHeight property from the System.Windows namespace:

<Button xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        Height="{x:Static SystemParameters.IconHeight}"/>

As with x:Type, the specified argument must be qualified with an XML namespace prefix if the member doesn’t belong in the default namespace. In this case, System.Windows is one of the .NET namespaces mapped to http://schemas.microsoft.com/winfx/2006/xaml/presentation ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required