This documentation is archived and is not being maintained.

NullExtension Class

Implements a XAML markup extension in order to return a null object, which you can use to explicitly set values to null in XAML.

Namespace:  System.Windows.Markup
Assembly:  System.Xaml (in System.Xaml.dll)
XMLNS for XAML: Not mapped to an xmlns.

public class NullExtension : MarkupExtension

The NullExtension type exposes the following members.

Public methodNullExtensionInitializes a new instance of the NullExtension class.

Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodProvideValueProvides null to use as a value as the output of this markup extension. (Overrides MarkupExtension.ProvideValue(IServiceProvider).)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

In XAML, null and empty string are generally not equivalent. You use the {x:Null} extension usage in order to set an attribute that sets the underlying property to null. For more information on how setting null values is relevant for scenarios in XAML, see x:Null Markup Extension.

This class is a markup extension implementation. Markup extension classes exist mainly to provide infrastructure support for how XAML processors interpret a particular extension. The members that markup extension implementation classes expose are not typically intended to be called from your code. This markup extension class supports the x:Null Markup Extension usage for .NET XAML Services.

In previous versions of the .NET Framework, this class (and the x:Null markup extension XAML behavior support as well as the relevant xmlns mapping) existed in the WPF-specific assembly PresentationFramework. In .NET Framework version 4, NullExtension is in the System.Xaml assembly. This makes the x:Null usage available to applications using frameworks that reference .NET XAML Services. You do not need PresentationFramework as a referenced assembly so long as you are targeting .NET Framework 4. For more information, see Types Migrated from WPF to System.Xaml.

The System.Xaml assembly uses XmlnsDefinitionAttribute to map all types in the assembly to the XAML namespace for the XAML language ( Typically you declare a prefix for in a root element mapping and use the prefix x.

WPF Usage Notes

For WPF dependency properties, when you set a dependency property value to null, you are not necessarily setting the property to its default value, even if it is a reference property. The default value of a dependency property depends on its dependency property registration. An unset value is not necessarily null either; see UnsetValue. For more information, see ClearValue or Dependency Properties Overview.

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.