DependencyProperty.UnsetValue 欄位

定義

指定 WPF 屬性系統所使用的靜態值,而不是 null 表示屬性存在,但未由屬性系統設定其值。

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

欄位值

備註

UnsetValue 是 sentinel 值,用於 WPF 屬性系統無法判斷要求 DependencyProperty 值的案例。 UnsetValue 是使用 而非 null ,因為 null 可能是有效的屬性值,以及有效的 (,而且經常使用) DefaultValue

UnsetValue 永遠不會從 傳 DependencyObject.GetValue 回 。 當您呼叫 DependencyObject.GetValue 實例上的 DependencyObject 相依性屬性時,適用下列其中一項:

  • 相依性屬性具有在中繼資料中建立的預設值,而且會傳回該值。 此值可能來自 DefaultMetadata

  • 屬性系統已建立一些其他值,而且預設值不再相關。 如需詳細資訊,請參閱相依性屬性值優先順序

DefaultValue特別不允許設定 的 UnsetValue

DependencyObject.ReadLocalValue 當要求的屬性尚未在本機設定時,會傳 UnsetValue 回 。

UnsetValue 當做 的 CoerceValueCallback 傳回值使用時,具有特殊意義。 如需詳細資訊,請參閱 相依性屬性回呼和驗證

如果您要系結至資料庫,請注意, UnsetValue 不等於 ,其方式與 true Value null 不相等 Value

適用於