Export (0) Print
Expand All

x:Null Markup Extension

Specifies null as a value for a XAML member.

<object property="{x:Null}" .../>

The keyword for a null reference in C# and C++ is null. The Microsoft Visual Basic keyword for a null reference is Nothing, but you always use {x:Null} as the XAML usage regardless which code-behind language you associate with the XAML.

The x:Null markup extension has no settable properties.

A null usage is often associated with the XAML member exposure of a CLR Nullable<T> value.

The x:Null markup extension, like all XAML markup extensions, uses the braces ({,}) for escaping the handling of attribute values to be other than literals or event-handler references. Attribute syntax is the syntax most frequently used with this markup extension. An object element syntax <x:Null /> is technically possible, but is rarely used because the x:Null markup extension has no positional parameters or construction arguments.

For information about markup extensions, see Markup Extensions and WPF XAML.

In .NET Framework XAML Services, the handling for this markup extension is defined by the NullExtension class.

WPF Usage Notes

Note that null is not necessarily the initial unset value for a reference-type dependency property. The initial default value can vary for each dependency property and can be based on property-specific metadata. Many dependency properties do not accept null as a value, either through markup or code because of their validation callback implementations. For more information about dependency properties, see Dependency Properties Overview.

Show:
© 2014 Microsoft