DependencyProperty.UnsetValue 字段

定义

指定一个由 WPF 属性系统使用的静态值,而不是 null 指示该属性存在,但不具有属性系统设置的值。Specifies a static value that is used by the WPF property system rather than null to indicate that the property exists, but does not have its value set by the property system.

public: static initonly System::Object ^ UnsetValue;
public static readonly object UnsetValue;
 staticval mutable UnsetValue : obj
Public Shared ReadOnly UnsetValue As Object 

字段值

Object

注解

UnsetValue 是一个 sentinel 值,用于 WPF 属性系统无法确定请求的值的方案 DependencyPropertyUnsetValue is a sentinel value that is used for scenarios where the WPF property system is unable to determine a requested DependencyProperty value. UnsetValue 使用而不是 null ,因为 null 可以是有效的属性值,也可以是有效的 (并且经常使用) DefaultValueUnsetValue is used rather than null, because null could be a valid property value, as well as a valid (and frequently used) DefaultValue.

UnsetValue 永远不会从中返回 DependencyObject.GetValueUnsetValue is never returned out of DependencyObject.GetValue. 对实例调用 DependencyObject.GetValue 依赖属性时 DependencyObject ,以下情况之一适用:When you call DependencyObject.GetValue on a dependency property on a DependencyObject instance, one of the following applies:

  • 依赖属性具有在元数据中建立的默认值,并且返回该值。A dependency property has a default value established in metadata and that value is returned. 此值可能来自 DefaultMetadataThis value might come from DefaultMetadata.

  • 其他一些值由属性系统建立,并且默认值不再相关。Some other value was established by the property system, and the default value is no longer relevant. 有关详细信息,请参阅依赖属性值优先级For details, see Dependency Property Value Precedence.

DefaultValue UnsetValue 特别不允许设置的。Setting a DefaultValue of UnsetValue is specifically disallowed.

DependencyObject.ReadLocalValueUnsetValue如果尚未本地设置请求的属性,则返回。DependencyObject.ReadLocalValue returns UnsetValue when the requested property has not been locally set.

UnsetValue 当用作的返回值时,具有特殊意义 CoerceValueCallbackUnsetValue has a special meaning when used as the return value of a CoerceValueCallback. 有关详细信息,请参阅 依赖属性回调和验证For details, see Dependency Property Callbacks and Validation.

如果要绑定到数据库,请注意,与不等效于 UnsetValue Value ,这与不等效于 Value true null 的方式相同。If you are binding to a database, note that UnsetValue is not equivalent to Value, in a similar way to how Value is not equivalent to a true null.

适用于