BindableAttribute Sınıf

Tanım

Bir üyenin genellikle bağlama için kullanılıp kullanılmadığını belirtir. Bu sınıf devralınamaz.

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
Devralma
BindableAttribute
Öznitelikler

Örnekler

Aşağıdaki kod örneği, verileri bağlamak için bir özelliği uygun olarak işaretler.

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

Sonraki kod örneğinde için BindableAttributedeğerinin nasıl denetlenecek olduğu MyProperty gösterilir. İlk olarak, kod nesnesinin tüm özellikleriyle bir PropertyDescriptorCollection alır. Ardından, kod almak için dizinini PropertyDescriptorCollection oluşturur MyProperty. Son olarak, kod bu özelliğin özniteliklerini döndürür ve bunları öznitelikler değişkenine kaydeder. Kod örneği, BindableAttributedeğerini denetlemenin iki farklı yolunu sunar. İkinci kod parçasında örnek yöntemini çağırır Equals . Son kod parçasında, örnek değerini denetlemek için özelliğini kullanır 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

bir sınıfı ile BindableAttributeişaretlediyseniz, değeri denetlemek için aşağıdaki kod örneğini kullanın.

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

Açıklamalar

Bu özniteliği bir denetimdeki birden çok üye için (genellikle özellikler) belirtebilirsiniz.

Bir özellik BindableAttributetrueolarak ayarlandıysa, bu özellik için bir özellik değişikliği bildirimi tetiklenmelidir. Bu, Bindable özelliği Yesise iki yönlü veri bağlamanın desteklendiği anlamına gelir. Bindable Noise, özelliğine yine de bağlanabilirsiniz, ancak özellik değişikliği bildirimini tetikleyebileceğinden veya tetikleyebileceğinden, bağlanılacak varsayılan özellik kümesinde gösterilmemelidir.

Note

BindableAttribute trueolarak ayarlanmış bir özelliği işaretlediğinizde, bu özniteliğin değeri Yessabit üye olarak ayarlanır. olarak ayarlanmış olarak BindableAttribute işaretlenmiş bir özellik için falsedeğeri şeklindedir No. Bu nedenle, kodunuzda bu özniteliğin değerini denetlemek için özniteliğini BindableAttribute.Yes veya BindableAttribute.Noolarak belirtmeniz gerekir.

Caution

Bu özniteliği yalnızca tasarım zamanında kullanabilirsiniz. Hiçbir şey çalışma zamanında herhangi bir özelliğe bağlamanızı engellemez.

Daha fazla bilgi için bkz . Öznitelikler.

Oluşturucular

Name Description
BindableAttribute(BindableSupport, BindingDirection)

BindableAttribute sınıfının yeni bir örneğini başlatır.

BindableAttribute(BindableSupport)

Değerlerden biriyle sınıfının yeni bir örneğini BindableAttributeBindableSupport başlatır.

BindableAttribute(Boolean, BindingDirection)

BindableAttribute sınıfının yeni bir örneğini başlatır.

BindableAttribute(Boolean)

Boole değeriyle BindableAttribute sınıfının yeni bir örneğini başlatır.

Alanlar

Name Description
Default

BindableAttributeolan Noiçin varsayılan değeri belirtir. Bu alan salt okunurdur.

No

Bir özelliğin genellikle bağlama için kullanılmadığını belirtir. Bu alan salt okunurdur.

Yes

Bir özelliğin genellikle bağlama için kullanıldığını belirtir. Bu alan salt okunurdur.

Özellikler

Name Description
Bindable

Bir özelliğin genellikle bağlama için kullanıldığını belirten bir değer alır.

Direction

Bu özelliğin veri bağlamasının yönünü veya yönlerini gösteren bir değer alır.

TypeId

Türetilmiş bir sınıfta uygulandığında, bu Attributeiçin benzersiz bir tanımlayıcı alır.

(Devralındığı yer: Attribute)

Yöntemler

Name Description
Equals(Object)

İki BindableAttribute nesnesinin eşit olup olmadığını belirler.

GetHashCode()

BindableAttribute sınıfı için karma işlevi görür.

GetType()

Geçerli örneğin Type alır.

(Devralındığı yer: Object)
IsDefaultAttribute()

Bu özniteliğin varsayılan olup olmadığını belirler.

Match(Object)

Türetilmiş bir sınıfta geçersiz kılındığında, bu örneğin belirtilen bir nesneye eşit olup olmadığını gösteren bir değer döndürür.

(Devralındığı yer: Attribute)
MemberwiseClone()

Geçerli Objectbasit bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Geçerli nesneyi temsil eden bir dize döndürür.

(Devralındığı yer: Object)

Belirtik Arabirim Kullanımları

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

Bir ad kümesini karşılık gelen bir dağıtma tanımlayıcısı kümesine eşler.

(Devralındığı yer: Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Bir arabirimin tür bilgilerini almak için kullanılabilecek bir nesnenin tür bilgilerini alır.

(Devralındığı yer: Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Bir nesnenin sağladığı tür bilgisi arabirimlerinin sayısını alır (0 ya da 1).

(Devralındığı yer: Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Bir nesne tarafından kullanıma sunulan özelliklere ve yöntemlere erişim sağlar.

(Devralındığı yer: Attribute)

Şunlara uygulanır

Ayrıca bkz.