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

適用於

另請參閱