BindableAttribute.Bindable 屬性

定義

取得值,指出屬性通常用於繫結。Gets a value indicating that a property is typically used for binding.

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

屬性值

如果屬性通常用於繫結,則為 true,否則為 falsetrue if the property is typically used for binding; otherwise, false.

範例

下列程式碼範例會檢查是否MyProperty為可系結。The following code example checks to see whether MyProperty is bindable. 首先, MyProperty程式碼會藉由執行下列動作來取得的屬性:First the code gets the attributes for MyProperty by doing the following:

然後,程式碼會myAttribute將設定為BindableAttributeAttributeCollection的值,並檢查屬性是否為可系結。Then, the code sets myAttribute to the value of the BindableAttribute in the AttributeCollection and checks whether the property is bindable.

若要讓這個程式碼範例執行,您必須提供完整的元件名稱。For this code example to run, you must provide the fully qualified assembly name. 如需如何取得完整元件名稱的詳細資訊,請參閱。For information about how to obtain the fully qualified assembly name, see

元件名稱Assembly Names.

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

適用於

另請參閱