Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

x:Null Markup Extension

Silverlight

Specifies null as a value for a property being set through a XAML attribute.

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

<object>
  <object.property>
    <x:Null />
  </object.property>
</object>

null is the keyword for a null reference in many managed programming languages. The Visual Basic keyword for a null reference is Nothing.

The x:Null markup extension has no settable properties.

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. Many dependency properties will not accept null as a value, either through markup or code, due to their internal implementation. In such cases, setting a XAML attribute value with x:Null can result in a parser exception.

x:Null is a markup extension. Makup extensions in XAML use the { and } characters as recognized by XAML processor implementations for escaping the handling of attribute values to be other than literals or handler references. Attribute syntax is the most common syntax used with this markup extension. x:Null may also be used in property element syntax.

Some Silverlight types are nullable. In cases where a nullable type does not already have null as the default, you could use x:Null to set to the null value in XAML.

If targeting Silverlight 3, you cannot use the object element form <x:Null>

Community Additions

Show:
© 2016 Microsoft