Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

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

ADD
Show:
© 2015 Microsoft