DependencyProperty.UnsetValue DependencyProperty.UnsetValue DependencyProperty.UnsetValue DependencyProperty.UnsetValue Field

定义

指定由 WPFWPF 属性系统使用的静态值而非 null,以指示属性存在,但其值未经属性系统设置。Specifies a static value that is used by the WPFWPF 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 

字段值

注解

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

UnsetValue永远不会从DependencyObject.GetValue中返回。UnsetValue is never returned out of DependencyObject.GetValue. DependencyObject实例调用DependencyObject.GetValue依赖属性时, 以下情况之一适用: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.

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

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

UnsetValue当用作的返回值CoerceValueCallback时, 具有特殊意义。UnsetValue 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.

适用于