Export (0) Print
Expand All

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.

'Declaration
<MarkupExtensionReturnTypeAttribute(GetType(Object))> _
Public Class NullExtension _
	Inherits MarkupExtension

The NullExtension type exposes the following members.

  NameDescription
Public methodNullExtensionInitializes a new instance of the NullExtension class.
Top

  NameDescription
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 the default hash function. (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 Nothing 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.)
Top

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 Nothing. 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 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 (http://schemas.microsoft.com/winfx/2006/xaml). Typically you declare a prefix for http://schemas.microsoft.com/winfx/2006/xaml 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 Nothing, 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 Nothing either; see UnsetValue. For more information, see ClearValue or Dependency Properties Overview.

.NET Framework

Supported in: 4.6, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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.
Show:
© 2014 Microsoft