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因為可能是有效的屬性值, 也是有效的 (而且經常使用) 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.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.

特別不允許UnsetValue設定的。DefaultValueSetting a DefaultValue of UnsetValue is specifically disallowed.

DependencyObject.ReadLocalValueUnsetValue當要求的屬性尚未在本機設定時傳回。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不等於, 與不等於 true null 的方式Value相似。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.

適用於