BindableAttributeとは? わかりやすく解説

BindableAttribute クラス

メンバが通常、バインディングに使用されるかどうかを指定します。このクラスは継承できません。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

<AttributeUsageAttribute(AttributeTargets.All)> _
Public NotInheritable Class
 BindableAttribute
    Inherits Attribute
Dim instance As BindableAttribute
[AttributeUsageAttribute(AttributeTargets.All)] 
public sealed class BindableAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::All)] 
public ref class BindableAttribute sealed :
 public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.All) */ 
public final class BindableAttribute extends
 Attribute
AttributeUsageAttribute(AttributeTargets.All) 
public final class BindableAttribute extends
 Attribute
解説解説

詳細については、属性の概要、属性を使用したメタデータの拡張 の各トピックを参照してください。

使用例使用例

プロパティがデータのバインド先として適切であることをマークするコード例を次に示します。

<Bindable(True)> _
Public Property MyProperty() As
 Integer
    Get
        ' Insert code here.
        Return 0
    End Get
    Set
         ' Insert code here.
    End Set
End Property
[Bindable(true)]
 public int MyProperty {
    get {
       // Insert code here.
       return 0;
    }
    set {
       // Insert code here.
    }
 }
property int MyProperty 
{
   [System::ComponentModel::Bindable(true)]
   int get()
   {
      // Insert code here.
      return 0;
   }

   [System::ComponentModel::Bindable(true)]
   void set( int )
   {
      // Insert code here.
   }
}
/** @attribute Bindable(true)
 */
/** @property 
 */
public int get_MyProperty()
{
    // Insert code here.
    return 0;
} //get_MyProperty()

/** @property 
 */
public void set_MyProperty(int
 value)
{
    // Insert code here.
} //set_MyProperty

MyProperty の BindableAttribute の値を確認する方法を次のコード例に示します。最初に、オブジェクトのすべてのプロパティを保持する PropertyDescriptorCollection を取得します。次に、PropertyDescriptorCollection にインデックスを付けて、MyProperty を取得します。最後に、このプロパティの属性を返し、それらの属性を属性変数に保存します。このコード例は、BindableAttribute の値を確認する 2 種類の方法を示しています。2 番目のコード片では、Equals メソッドを呼び出します。最後のコード片では、Bindable プロパティを使用して値を確認します。

    ' Gets the attributes for the property.
    Dim attributes As AttributeCollection =
 _
        TypeDescriptor.GetProperties(Me)("MyProperty").Attributes
    
    ' Checks to see if the value of the BindableAttribute is Yes.
    If attributes(GetType(BindableAttribute)).Equals(BindableAttribute.Yes)
 Then
        ' Insert code here.
    End If 
    
    ' This is another way to see whether the property is bindable.
    Dim myAttribute As BindableAttribute =
 _
        CType(attributes(GetType(BindableAttribute)), BindableAttribute)
    If myAttribute.Bindable Then
        ' Insert code here.
    End If 

 ' Yet another way to see whether the property is bindable.
If attributes.Contains(BindableAttribute.Yes) Then
' Insert code here.
End If

   // Gets the attributes for the property.
    AttributeCollection attributes = 
       TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;
    
    // Checks to see if the value of the BindableAttribute is Yes.
    if(attributes[typeof(BindableAttribute)].Equals(BindableAttribute.Yes))
 {
       // Insert code here.
    }
    
    // This is another way to see whether the property is bindable.
    BindableAttribute myAttribute = 
       (BindableAttribute)attributes[typeof(BindableAttribute)];
    if(myAttribute.Bindable) {
       // Insert code here.
    }

// Yet another way to see whether the property is bindable.
if (attributes.Contains(BindableAttribute.Yes)) {
   // Insert code here.
}

using namespace System::ComponentModel;

// Gets the attributes for the property.
AttributeCollection^ attributes = TypeDescriptor::GetProperties( this
 )[ "MyProperty" ]->Attributes;

// Checks to see if the value of the BindableAttribute is Yes.
if ( attributes[ BindableAttribute::typeid ]->Equals( BindableAttribute::Yes
 ) )
{
   // Insert code here.
}

// This is another way to see whether the property is bindable.
BindableAttribute^ myAttribute = static_cast<BindableAttribute^>(attributes[
 BindableAttribute::typeid ]);
if ( myAttribute->Bindable )
{
   // Insert code here.
}

// Yet another way to see whether the property is bindable.
if ( attributes->Contains( BindableAttribute::Yes ) )
{
   // Insert code here.
}
// Gets the attributes for the property.
AttributeCollection attributes = TypeDescriptor.GetProperties(this)
    .get_Item("MyProperty").get_Attributes();

// Checks to see if the value of the BindableAttribute is Yes.
if (attributes.get_Item(BindableAttribute.class.ToType())
    .Equals(BindableAttribute.Yes)) {
    // Insert code here.
}

// This is another way to see whether the property is bindable.
BindableAttribute myAttribute = (BindableAttribute)
    (attributes.get_Item(BindableAttribute.class.ToType()));
if (myAttribute.get_Bindable()) {
    // Insert code here.
}

// Yet another way to see whether the property is bindable.
if (attributes.Contains(BindableAttribute.Yes)) {
    // Insert code here.
}

BindableAttribute を使用してクラスをマークした場合は、次のコード例を使用して値を確認します。

Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(MyProperty)
If attributes(GetType(BindableAttribute)).Equals(BindableAttribute.Yes)
 Then
    ' Insert code here.
End If 
AttributeCollection attributes = 
    TypeDescriptor.GetAttributes(MyProperty);
 if(attributes[typeof(BindableAttribute)].Equals(BindableAttribute.Yes))
 {
    // Insert code here.
 }
using namespace System::ComponentModel;
AttributeCollection^ attributes = TypeDescriptor::GetAttributes( MyProperty );
if ( attributes[ BindableAttribute::typeid ]->Equals( BindableAttribute::Yes
 ) )
{
   // Insert code here.
}
AttributeCollection attributes = 
        TypeDescriptor.GetAttributes((Int32)get_MyProperty());
if (attributes.get_Item(BindableAttribute.class.ToType())
    .Equals(BindableAttribute.Yes)) {
    // Insert code here.
}
継承階層継承階層
System.Object
   System.Attribute
    System.ComponentModel.BindableAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BindableAttribute メンバ
System.ComponentModel 名前空間
Attribute
PropertyDescriptor
AttributeCollection クラス
PropertyDescriptorCollection

BindableAttribute コンストラクタ (BindableSupport)

BindableSupport 値の 1 つを指定して、BindableAttribute クラスの新しいインスタンスを初期化します。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

Public Sub New ( _
    flags As BindableSupport _
)
Dim flags As BindableSupport

Dim instance As New BindableAttribute(flags)
public BindableAttribute (
    BindableSupport flags
)
public:
BindableAttribute (
    BindableSupport flags
)
public BindableAttribute (
    BindableSupport flags
)
public function BindableAttribute (
    flags : BindableSupport
)

パラメータ

flags

BindableSupport 値の 1 つ。

解説解説

BindableAttribute に true を設定してプロパティをマークすると、この属性の値は定数メンバ Yes に設定されます。false に設定された BindableAttribute でマークしたプロパティの場合、値は No になります。したがって、コード内でこの属性の値を確認する場合は、この属性を BindableAttribute.Yes または BindableAttribute.No として指定する必要があります。

使用例使用例

プロパティがデータのバインド先として適切であることをマークするコード例を次に示します。このコード例では、新しい BindableAttribute を作成し、その値を BindableAttribute.Yes に設定してから、その属性をプロパティに関連付けます。

<Bindable(BindableSupport.Yes)> _
Public Property MyProperty As
 Integer
   Get
      ' Insert code here.
      Return 0
   End Get
   Set
      ' Insert code here.
   End Set
End Property
  
[Bindable(BindableSupport.Yes)]
 public int MyProperty {
    get {
       // Insert code here.
       return 0;
    }
    set {
       // Insert code here.
    }
 }
   
   [Bindable(BindableSupport::Yes)]
   int get()
   {
      
      // Insert code here.
      return 0;
   }

   void set( int theValue
 )
   {
      
      // Insert code here.
   }

}
/** @attribute Bindable(BindableSupport.Yes)
 */
/** @property 
 */
public int get_MyProperty()
{
    // Insert code here.
    return 0;
} //get_MyProperty

/** @property 
 */
public void set_MyProperty(int
 value)
{
    // Insert code here.
} //set_MyProperty
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BindableAttribute クラス
BindableAttribute メンバ
System.ComponentModel 名前空間
BindableAttribute クラス
BindableSupport

BindableAttribute コンストラクタ (Boolean, BindingDirection)

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

BindableAttribute クラスの新しいインスタンスを初期化します。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

Public Sub New ( _
    bindable As Boolean, _
    direction As BindingDirection _
)
Dim bindable As Boolean
Dim direction As BindingDirection

Dim instance As New BindableAttribute(bindable,
 direction)
public BindableAttribute (
    bool bindable,
    BindingDirection direction
)
public:
BindableAttribute (
    bool bindable, 
    BindingDirection direction
)
public BindableAttribute (
    boolean bindable, 
    BindingDirection direction
)
public function BindableAttribute (
    bindable : boolean, 
    direction : BindingDirection
)

パラメータ

bindable

プロパティをバインディングに使用する場合は true。それ以外の場合は false。

direction

BindingDirection 値の 1 つ。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

BindableAttribute コンストラクタ (Boolean)

Boolean 値を指定して、BindableAttribute クラスの新しいインスタンスを初期化します。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

Public Sub New ( _
    bindable As Boolean _
)
Dim bindable As Boolean

Dim instance As New BindableAttribute(bindable)
public BindableAttribute (
    bool bindable
)
public:
BindableAttribute (
    bool bindable
)
public BindableAttribute (
    boolean bindable
)
public function BindableAttribute (
    bindable : boolean
)

パラメータ

bindable

プロパティをバインディングに使用する場合は true。それ以外の場合は false。

解説解説

BindableAttribute に true を設定してプロパティをマークすると、この属性の値は定数メンバ Yes に設定されます。false に設定された BindableAttribute でマークしたプロパティの場合、値は No になります。したがって、コード内でこの属性の値を確認する場合は、この属性を BindableAttribute.Yes または BindableAttribute.No として指定する必要があります。

使用例使用例

プロパティがデータのバインド先として適切であることをマークするコード例を次に示します。このコード例では、新しい BindableAttribute を作成し、その値を BindableAttribute.Yes に設定してから、その属性をプロパティに関連付けます。

<Bindable(true)> _
Public Property MyProperty As
 Integer
   Get
      ' Insert code here.
      Return 0
   End Get
   Set
      ' Insert code here.
   End Set
End Property
  
[Bindable(true)]
 public int MyProperty {
    get {
       // Insert code here.
       return 0;
    }
    set {
       // Insert code here.
    }
 }
   
public:
   [property:Bindable(true)]
   property int MyProperty 
   {
      int get()
      {
         // Insert code here.
         return 0;
      }
      void set( int theValue
 )
      {
         // Insert code here.
      }
   }
/** @attribute Bindable(true)
 */
/** @property 
 */
public int get_MyProperty()
{
    // Insert code here.
    return 0;
} //get_MyProperty

/** @property 
 */
public void set_MyProperty(int
 value)
{
    // Insert code here.
} //set_MyProperty
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BindableAttribute クラス
BindableAttribute メンバ
System.ComponentModel 名前空間
BindableAttribute クラス

BindableAttribute コンストラクタ (BindableSupport, BindingDirection)

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

BindableAttribute クラスの新しいインスタンスを初期化します。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

Public Sub New ( _
    flags As BindableSupport, _
    direction As BindingDirection _
)
Dim flags As BindableSupport
Dim direction As BindingDirection

Dim instance As New BindableAttribute(flags,
 direction)
public BindableAttribute (
    BindableSupport flags,
    BindingDirection direction
)
public:
BindableAttribute (
    BindableSupport flags, 
    BindingDirection direction
)
public BindableAttribute (
    BindableSupport flags, 
    BindingDirection direction
)
public function BindableAttribute (
    flags : BindableSupport, 
    direction : BindingDirection
)

パラメータ

flags

BindableSupport 値の 1 つ。

direction

BindingDirection 値の 1 つ。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

BindableAttribute コンストラクタ

BindableAttribute クラスの新しいインスタンスを初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
BindableAttribute (BindableSupport) BindableSupport 値の 1 つを指定して、BindableAttribute クラスの新しいインスタンスを初期化します。
BindableAttribute (Boolean) Boolean 値を指定して、BindableAttribute クラスの新しいインスタンスを初期化します。
BindableAttribute (BindableSupport, BindingDirection) BindableAttribute クラスの新しいインスタンスを初期化します。
BindableAttribute (Boolean, BindingDirection) BindableAttribute クラスの新しいインスタンスを初期化します。
参照参照

関連項目

BindableAttribute クラス
BindableAttribute メンバ
System.ComponentModel 名前空間
BindableAttribute クラス
BindableSupport

BindableAttribute フィールド


BindableAttribute プロパティ


パブリック プロパティパブリック プロパティ

参照参照

関連項目

BindableAttribute クラス
System.ComponentModel 名前空間
Attribute
PropertyDescriptor
AttributeCollection クラス
PropertyDescriptorCollection

BindableAttribute メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Equals オーバーロードされます。 オーバーライドされます。 2 つの BindableAttribute オブジェクトが等しいかどうかを判断します。
パブリック メソッド GetCustomAttribute  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 ( Attribute から継承されます。)
パブリック メソッド GetHashCode オーバーライドされます。 BindableAttribute クラスのハッシュ関数として機能します。
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド IsDefaultAttribute オーバーライドされます。 この属性が既定値かどうかを判断します。
パブリック メソッド IsDefined  オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 ( Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 ( Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

BindableAttribute クラス
System.ComponentModel 名前空間
Attribute
PropertyDescriptor
AttributeCollection クラス
PropertyDescriptorCollection

BindableAttribute メンバ

メンバが通常、バインディングに使用されるかどうかを指定します。このクラスは継承できません。

BindableAttribute データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド BindableAttribute オーバーロードされます。 BindableAttribute クラスの新しいインスタンスを初期化します。
パブリック フィールドパブリック フィールド
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Equals オーバーロードされます。 オーバーライドされます。 2 つの BindableAttribute オブジェクトが等しいかどうかを判断します。
パブリック メソッド GetCustomAttribute  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 (Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 (Attribute から継承されます。)
パブリック メソッド GetHashCode オーバーライドされます。 BindableAttribute クラスのハッシュ関数として機能します。
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド IsDefaultAttribute オーバーライドされます。 この属性が既定値かどうかを判断します。
パブリック メソッド IsDefined  オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 (Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

BindableAttribute クラス
System.ComponentModel 名前空間
Attribute
PropertyDescriptor
AttributeCollection クラス
PropertyDescriptorCollection



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「BindableAttribute」の関連用語











BindableAttributeのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



BindableAttributeのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS