FrameworkPropertyMetadata.IsNotDataBindable 屬性

定義

取得或設定值,指出相依性屬性是否支援資料繫結。Gets or sets a value that indicates whether the dependency property supports data binding.

public:
 property bool IsNotDataBindable { bool get(); void set(bool value); };
public bool IsNotDataBindable { get; set; }
member this.IsNotDataBindable : bool with get, set
Public Property IsNotDataBindable As Boolean

屬性值

如果屬性不支援資料繫結,即為 true;否則為 falsetrue if the property does not support data binding; otherwise, false. 預設值為 falseThe default is false.

例外狀況

中繼資料已套用至相依性屬性作業,因此中繼資料已密封,而且無法設定中繼資料的屬性。The metadata has already been applied to a dependency property operation, so that metadata is sealed and properties of the metadata cannot be set.

備註

請注意,這個中繼資料屬性會設定為 true 特別針對不應支援資料系結的屬性(儘管是讀寫屬性)。Note that this metadata property is set to true specifically for properties that should not support data binding, despite being read-write properties. 預期的情況是在宣告相依性屬性的大部分情況下,需要資料系結,因為資料系結是相依性屬性有用的其中一個關鍵案例。The expectation is that in most cases where a dependency property is declared, data binding is desired, because data binding is one of the key scenarios where a dependency property is useful. 不同于 BindsTwoWayByDefault,這不只會變更稍後可以在特定系結上變更的預設值。Unlike BindsTwoWayByDefault, this does not merely change a default that can later be changed on a specific binding. 在相依性屬性中繼資料的中繼資料中設定這個屬性 true,將會停用所有系結,使其無法透過運算式將其值套用至該相依性屬性。Setting this property true in the metadata for a dependency property metadata will disable all bindings from applying their values through expressions to that dependency property.

唯讀相依性屬性不支援資料系結(因為它們沒有可以套用變更值的 setter),但仍會針對 IsNotDataBindable報告 falseRead-only dependency properties do not support data binding (because they have no setter that can apply changed values), but will still report false for IsNotDataBindable. 這是因為對應至 FrameworkPropertyMetadataOptions 值的屬性會與實際建立中繼資料的方式報告同位檢查,而不是一律報告屬性的命名可能表示的最終結果行為。This is because properties that correspond to a FrameworkPropertyMetadataOptions values will report parity with how the metadata was actually established, rather than always reporting the end result behavior that the naming of the property might imply. 若要判斷指定的相依性屬性是否允許資料系結,您通常應該改為檢查 IsDataBindingAllowedTo determine whether a given dependency property permits data binding, you should usually check IsDataBindingAllowed instead. IsDataBindingAllowed 是將 ReadOnlyIsNotDataBindable 檢查為單一作業的便利,會產生預期的結果。IsDataBindingAllowed is a convenience for checking both ReadOnly and IsNotDataBindable as a single operation, yielding the expected result.

PropertyMetadata 衍生類別上的屬性通常會在物件模型中定義為讀寫。Properties on derived classes of PropertyMetadata are typically defined in the object model as read-write. 如此一來,就可以在初始化實例之後調整。This is so they can be adjusted after initialization of the instance. 不過,在 RegisterAddOwnerOverrideMetadata的呼叫中取用中繼資料之後,屬性系統會密封該中繼資料實例和傳達中繼資料細節的屬性現在視為不變。However, after the metadata is consumed as part of a call to Register, AddOwner, or OverrideMetadata, the property system will seal that metadata instance and properties that convey the specifics of the metadata are now considered immutable. 嘗試在這個中繼資料實例上 true IsSealed 之後設定這個屬性,將會引發例外狀況。Attempting to set this property after IsSealed is true on this metadata instance will raise an exception.

XAML 文字使用方式XAML Text Usage

XAMLXAML中,通常不會使用這個類別的成員。Members of this class are not typically used in XAMLXAML.

適用於

另請參閱