BindableAttribute.Bindable 屬性

定義

會得到一個值,表示某屬性通常用於綁定。

public:
 property bool Bindable { bool get(); };
public bool Bindable { get; }
member this.Bindable : bool
Public ReadOnly Property Bindable As Boolean

屬性值

true如果該性質通常用於綁定;否則,。 false

範例

以下程式碼範例檢查是否 MyProperty 可綁定。 首先,程式碼透過以下步驟取得屬性 MyProperty

接著,程式碼將 設定myAttribute為 在 中的AttributeCollectionBindableAttribute,並檢查該屬性是否可綁定。

要執行此程式碼範例,您必須提供完全限定的組合名稱。 關於如何取得完全合格的組裝名稱,請參見

組裝名稱

// 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

適用於

另請參閱