BindableAttribute 클래스

정의

멤버가 일반적으로 바인딩에 사용되는지 여부를 지정합니다. 이 클래스는 상속될 수 없습니다.

public ref class BindableAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.All)]
public sealed class BindableAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.All)>]
type BindableAttribute = class
    inherit Attribute
Public NotInheritable Class BindableAttribute
Inherits Attribute
상속
BindableAttribute
특성

예제

다음 코드 예제에서는 데이터를 바인딩하는 데 적합한 속성을 표시합니다.

property int MyProperty 
{
   [System::ComponentModel::Bindable(true)]
   int get()
   {
      // Insert code here.
      return 0;
   }

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

다음 코드 예제에서는 의 값을 BindableAttributeMyProperty검사 하는 방법을 보여 입니다. 먼저 코드는 개체에 대한 모든 속성을 가진 을 가져옵니다 PropertyDescriptorCollection . 다음으로, 코드는 를 인 PropertyDescriptorCollection 덱싱하여 를 가져옵니다 MyProperty. 마지막으로 코드는 이 속성에 대한 특성을 반환하고 특성 변수에 저장합니다. 코드 예제에서는 의 값을 BindableAttribute검사 두 가지 방법을 제공합니다. 두 번째 코드 조각에서 예제는 메서드를 호출합니다 Equals . 마지막 코드 조각에서 사용 하 여는 Bindable 속성 값을 확인 합니다.

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)["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.
}
    ' 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

클래스BindableAttribute를 로 표시한 경우 다음 코드 예제를 사용하여 값을 검사.

using namespace System::ComponentModel;
AttributeCollection^ attributes = TypeDescriptor::GetAttributes( MyProperty );
if ( attributes[ BindableAttribute::typeid ]->Equals( BindableAttribute::Yes ) )
{
   // Insert code here.
}
AttributeCollection attributes =
    TypeDescriptor.GetAttributes(MyProperty);
 if(attributes[typeof(BindableAttribute)].Equals(BindableAttribute.Yes)) {
    // Insert code here.
 }
Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(MyProperty)
If attributes(GetType(BindableAttribute)).Equals(BindableAttribute.Yes) Then
    ' Insert code here.
End If

설명

컨트롤에서 여러 멤버(일반적으로 속성)에 대해 이 특성을 지정할 수 있습니다.

속성이 로 설정된 true것으로 BindableAttribute 표시된 경우 해당 속성에 대해 속성 변경 알림이 발생해야 합니다. 즉, 속성이 BindableYes인 경우 양방향 데이터 바인딩이 지원됩니다. 가 이NoBindable 속성에 바인딩할 수 있지만 속성 변경 알림을 발생하거나 발생시키지 않을 수 있으므로 바인딩할 기본 속성 집합에 표시되지 않아야 합니다.

참고

로 설정된 true속성을 BindableAttribute 표시하면 이 특성의 값이 상수 멤버 Yes로 설정됩니다. 로 설정된 false것으로 표시된 속성의 BindableAttribute 경우 값은 입니다No. 따라서 코드에서 이 특성의 값을 검사 특성을 또는 BindableAttribute.NoBindableAttribute.Yes 지정해야 합니다.

주의

디자인 타임에만 이 특성을 사용할 수 있습니다. 아무것도 런타임 동안 속성에 바인딩할 수 없습니다.

자세한 내용은 특성을 참조하세요.

생성자

BindableAttribute(BindableSupport)

BindableSupport 값 중 하나를 사용하여 BindableAttribute 클래스의 새 인스턴스를 초기화합니다.

BindableAttribute(BindableSupport, BindingDirection)

BindableAttribute 클래스의 새 인스턴스를 초기화합니다.

BindableAttribute(Boolean)

부울 값을 사용하여 BindableAttribute 클래스의 새 인스턴스를 초기화합니다.

BindableAttribute(Boolean, BindingDirection)

BindableAttribute 클래스의 새 인스턴스를 초기화합니다.

필드

Default

BindableAttribute의 기본값인 No을 지정합니다. 이 필드는 읽기 전용입니다.

No

일반적으로 바인딩에 속성이 사용되지 않도록 지정합니다. 이 필드는 읽기 전용입니다.

Yes

일반적으로 바인딩에 속성이 사용되도록 지정합니다. 이 필드는 읽기 전용입니다.

속성

Bindable

일반적으로 바인딩에 속성이 사용됨을 나타내는 값을 가져옵니다.

Direction

이 속성의 데이터 바인딩 방향을 나타내는 값을 가져옵니다.

TypeId

파생 클래스에서 구현된 경우 이 Attribute에 대한 고유 식별자를 가져옵니다.

(다음에서 상속됨 Attribute)

메서드

Equals(Object)

BindableAttribute 개체가 서로 같은지 확인합니다.

GetHashCode()

BindableAttribute 클래스에 대한 해시 함수 역할을 합니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
IsDefaultAttribute()

이 특성이 기본값인지 여부를 확인합니다.

Match(Object)

파생 클래스에서 재정의된 경우 이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다.

(다음에서 상속됨 Attribute)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

이름 집합을 해당하는 디스패치 식별자 집합에 매핑합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

개체에서 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1).

(다음에서 상속됨 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

개체에서 노출하는 메서드와 속성에 대한 액세스를 제공합니다.

(다음에서 상속됨 Attribute)

적용 대상

추가 정보