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 の属性を取得します。

  • オブジェクトのすべてのプロパティを含む PropertyDescriptorCollection を取得します。

  • MyPropertyを取得するためにPropertyDescriptorCollectionにインデックスを作成する。

  • このプロパティの属性を attributes 変数に保存します。

次に、コードはmyAttributeAttributeCollection内の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

適用対象

こちらもご覧ください