ערוך

שתף באמצעות


NullExtension Class

Definition

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

public ref class NullExtension : System::Windows::Markup::MarkupExtension
[System.Windows.Markup.MarkupExtensionReturnType(typeof(System.Object))]
public class NullExtension : System.Windows.Markup.MarkupExtension
[<System.Windows.Markup.MarkupExtensionReturnType(typeof(System.Object))>]
type NullExtension = class
    inherit MarkupExtension
Public Class NullExtension
Inherits MarkupExtension
Inheritance
NullExtension
Attributes

Remarks

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 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 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.

Constructors

NullExtension()

Initializes a new instance of the NullExtension class.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ProvideValue(IServiceProvider)

Provides null to use as a value as the output of this markup extension.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also