NullExtension 类

定义

实现 XAML 标记以返回 null 对象,可使用该对象在 XAML 中将值显式设置为 null。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
type NullExtension = class
    inherit MarkupExtension
Public Class NullExtension
Inherits MarkupExtension
继承
NullExtension
属性

注解

在 XAML 中, null 和空字符串通常不等效。In XAML, null and empty string are generally not equivalent. 使用{x:Null}扩展用法可以设置将基础属性设置为null的特性。You use the {x:Null} extension usage in order to set an attribute that sets the underlying property to null. 有关设置 null 值如何与 XAML 中的方案相关的详细信息, 请参阅X: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. 标记扩展类主要用于为 XAML 处理器解释特定扩展的方式提供基础结构支持。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. 此标记扩展类支持 .NET XAML 服务的X:Null 标记扩展用法。This markup extension class supports the x:Null Markup Extension usage for .NET XAML Services.

在 .NET Framework 的以前版本中, 此类 (以及x:Null标记扩展 XAML 行为支持以及相关的 xmlns 映射) 存在于 WPF 特定的程序集 PresentationFramework 中。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. .NET Framework 4.NET Framework 4NullExtension , 为 system.exception 程序集。In .NET Framework 4.NET Framework 4, NullExtension is in the System.Xaml assembly. 这使x:Null使用情况可用于使用引用 .net XAML 服务的框架的应用程序。This makes the x:Null usage available to applications using frameworks that reference .NET XAML Services. 只要目标.NET Framework 4.NET Framework 4为, 就不需要 PresentationFramework 作为引用的程序集。You do not need PresentationFramework as a referenced assembly so long as you are targeting .NET Framework 4.NET Framework 4. 有关详细信息,请参阅 Types Migrated from WPF to System.XamlFor more information, see Types Migrated from WPF to System.Xaml.

系统 .xaml 程序集使用XmlnsDefinitionAttribute将程序集中的所有类型映射到 xaml 语言 (http://schemas.microsoft.com/winfx/2006/xaml) 的 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). 通常, http://schemas.microsoft.com/winfx/2006/xaml在根元素映射中声明前缀, 并使用前缀xTypically you declare a prefix for http://schemas.microsoft.com/winfx/2006/xaml in a root element mapping and use the prefix x.

WPF 用法说明WPF Usage Notes

对于 WPF 依赖项属性, 将依赖项属性值设置为null时, 不一定要将属性设置为其默认值, 即使它是引用属性也是如此。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. 未设置的值不一定null是; 请UnsetValue参见。An unset value is not necessarily null either; see UnsetValue. 有关详细信息, 请ClearValue参阅或依赖属性概述For more information, see ClearValue or Dependency Properties Overview.

构造函数

NullExtension()

初始化 NullExtension 类的新实例。Initializes a new instance of the NullExtension class.

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ProvideValue(IServiceProvider)

提供要用作值的 null 作为此标记扩展的输出。Provides null to use as a value as the output of this markup extension.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅