BindableAttribute Osztály
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Megadja, hogy egy tagot általában a kötéshez használnak-e. Ez az osztály nem örökölhető.
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
- Öröklődés
- Attribútumok
Példák
Az alábbi példakód egy tulajdonságot jelöl, amely megfelel az adatok kötésének.
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
A következő példakód bemutatja, hogyan ellenőrizheti a következő érték értékét BindableAttributeMyProperty. Először is a kód lekéri PropertyDescriptorCollection az objektum összes tulajdonságát. Ezután a kód indexel a PropertyDescriptorCollection lekéréshez MyProperty. Végül a kód visszaadja a tulajdonság attribútumait, és menti őket az attribútumváltozóba. A példakód két különböző módszert mutat be az érték BindableAttributeellenőrzésére. A második kódrészletben a példa meghívja a metódust Equals . Az utolsó kódrészletben a példa a Bindable tulajdonságot használja az érték ellenőrzéséhez.
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
Ha az osztályt a BindableAttributekövetkezővel jelölte meg, az érték ellenőrzéséhez használja az alábbi kód példáját.
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
Megjegyzések
Ezt az attribútumot több taghoz, általában tulajdonságokhoz is megadhatja egy vezérlőelemen.
Ha egy tulajdonság meg van jelölve a BindableAttribute beállítással true, akkor a tulajdonsághoz tulajdonságmódosítási értesítést kell létrehozni. Ez azt jelenti, hogy ha a Bindable tulajdonság, Yesakkor a kétirányú adatkötés támogatott. Ha Bindable igen No, akkor is kapcsolódhat a tulajdonsághoz, de nem jelenik meg az alapértelmezett kötési tulajdonságkészletben, mert előfordulhat, hogy tulajdonságmódosítási értesítést küld.
Note
Ha egy tulajdonságot a következő értékre BindableAttribute állít truebe, ennek az attribútumnak az értéke állandó tag Yeslesz. A beállítással BindableAttributefalsemegjelölt tulajdonság esetében az érték a következő No. Ezért az attribútum értékének a kódban való ellenőrzéséhez meg kell adnia az attribútumot BindableAttribute.YesBindableAttribute.No.
Figyelmeztetés
Ezt az attribútumot csak tervezési időben használhatja. A futási idő alatt semmi sem akadályozza meg, hogy bármilyen tulajdonsághoz kötődjön.
További információ: Attribútumok.
Konstruktorok
| Name | Description |
|---|---|
| BindableAttribute(BindableSupport, BindingDirection) |
Inicializálja a BindableAttribute osztály új példányát. |
| BindableAttribute(BindableSupport) |
Inicializálja az osztály új példányát az BindableAttributeBindableSupport egyik értékkel. |
| BindableAttribute(Boolean, BindingDirection) |
Inicializálja a BindableAttribute osztály új példányát. |
| BindableAttribute(Boolean) |
Inicializálja az BindableAttribute osztály új példányát logikai értékkel. |
Mezők
| Name | Description |
|---|---|
| Default |
Az alapértelmezett értéket adja meg a BindableAttribute( vagyis No) értékhez. Ez a mező csak olvasható. |
| No |
Azt adja meg, hogy egy tulajdonságot általában nem használnak kötéshez. Ez a mező csak olvasható. |
| Yes |
Azt határozza meg, hogy a rendszer általában egy tulajdonságot használ a kötéshez. Ez a mező csak olvasható. |
Tulajdonságok
| Name | Description |
|---|---|
| Bindable |
Lekéri azt az értéket, amely azt jelzi, hogy egy tulajdonságot általában a kötéshez használnak. |
| Direction |
A tulajdonság adatkötésének irányát vagy irányát jelző értéket kap. |
| TypeId |
Ha származtatott osztályban implementálják, ehhez egy egyedi azonosítót Attributekap. (Öröklődés forrása Attribute) |
Metódusok
| Name | Description |
|---|---|
| Equals(Object) |
Meghatározza, hogy két BindableAttribute objektum egyenlő-e. |
| GetHashCode() |
Az osztály kivonatfüggvénye BindableAttribute . |
| GetType() |
Lekéri az Type aktuális példányt. (Öröklődés forrása Object) |
| IsDefaultAttribute() |
Meghatározza, hogy ez az attribútum-e az alapértelmezett érték. |
| Match(Object) |
Származtatott osztály felülírásakor egy olyan értéket ad vissza, amely jelzi, hogy ez a példány egy adott objektummal egyenlő-e. (Öröklődés forrása Attribute) |
| MemberwiseClone() |
Az aktuális Objectpéldány sekély másolatát hozza létre. (Öröklődés forrása Object) |
| ToString() |
Az aktuális objektumot jelképező sztringet ad vissza. (Öröklődés forrása Object) |
Explicit interfész-implementációk
| Name | Description |
|---|---|
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Névkészletet képez le a küldési azonosítók megfelelő készletére. (Öröklődés forrása Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
Lekéri egy objektum típusadatait, amelyek a felület típusadatainak lekérésére használhatók. (Öröklődés forrása Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
Lekéri az objektumok által biztosított típusinformációs felületek számát (0 vagy 1). (Öröklődés forrása Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Hozzáférést biztosít az objektumok által közzétett tulajdonságokhoz és metódusokhoz. (Öröklődés forrása Attribute) |