BindableAttribute.Bindable 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
會得到一個值,表示某屬性通常用於綁定。
public:
property bool Bindable { bool get(); };
public bool Bindable { get; }
member this.Bindable : bool
Public ReadOnly Property Bindable As Boolean
屬性值
true如果該性質通常用於綁定;否則,。 false
範例
以下程式碼範例檢查是否 MyProperty 可綁定。 首先,程式碼透過以下步驟取得屬性 MyProperty :
取得包含所有物件屬性的 a PropertyDescriptorCollection 。
索引到取得 PropertyDescriptorCollection
MyProperty。將此屬性的屬性存入屬性變數。
接著,程式碼將 設定myAttribute為 在 中的AttributeCollection值BindableAttribute,並檢查該屬性是否可綁定。
要執行此程式碼範例,您必須提供完全限定的組合名稱。 關於如何取得完全合格的組裝名稱,請參見
組裝名稱。
// Gets the attributes for the property.
AttributeCollection^ attributes = TypeDescriptor::GetProperties( this )[ "MyProperty" ]->Attributes;
// Checks to see if the property is bindable.
BindableAttribute^ myAttribute = dynamic_cast<BindableAttribute^>(attributes[ BindableAttribute::typeid ]);
if ( myAttribute->Bindable )
{
// Insert code here.
}
// Gets the attributes for the property.
AttributeCollection attributes =
TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;
// Checks to see if the property is bindable.
BindableAttribute myAttribute = (BindableAttribute)attributes[typeof(BindableAttribute)];
if (myAttribute.Bindable)
{
// Insert code here.
}
' Gets the attributes for the property.
Dim attributes As AttributeCollection = _
TypeDescriptor.GetProperties(Me)("MyProperty").Attributes
' Checks to see if the property is bindable.
Dim myAttribute As BindableAttribute = _
CType(attributes(System.Type.GetType("BindableAttribute")), BindableAttribute)
If (myAttribute.Bindable) Then
' Insert code here.
End If