DependencyProperty.UnsetValue 欄位

定義

指定 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 可以是有效的屬性值,以及有效的(且經常使用的) 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.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.

特別不允許設定 UnsetValueDefaultValueSetting a DefaultValue of UnsetValue is specifically disallowed.

當要求的屬性尚未在本機設定時,DependencyObject.ReadLocalValue 會傳回 UnsetValueDependencyObject.ReadLocalValue returns UnsetValue when the requested property has not been locally set.

使用做為 CoerceValueCallback的傳回值時,UnsetValue 具有特殊意義。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.

適用於