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 ...
Get XAML Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.