BindableAttribute.Bindable Proprietà
In questo articolo
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene un valore che indica che una proprietà viene generalmente utilizzata per l'associazione.
public:
property bool Bindable { bool get(); };
public bool Bindable { get; }
member this.Bindable : bool
Public ReadOnly Property Bindable As Boolean
true
se la proprietà viene generalmente utilizzata per l'associazione. In caso contrario, false
.
Nell'esempio di codice seguente viene verificato se MyProperty
è associabile. Per prima cosa, il codice ottiene gli attributi per MyProperty
eseguendo le operazioni seguenti:
Recupero di un PropertyDescriptorCollection oggetto con tutte le proprietà per l'oggetto .
Indicizzazione in PropertyDescriptorCollection per ottenere
MyProperty
.Salvataggio degli attributi per questa proprietà nella variabile degli attributi.
Il codice imposta myAttribute
quindi sul valore di BindableAttribute in AttributeCollection e controlla se la proprietà è associabile.
Per eseguire questo esempio di codice, è necessario specificare il nome completo dell'assembly. Per informazioni su come ottenere il nome completo dell'assembly, vedere
// 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
Feedback su .NET
.NET è un progetto di open source. Selezionare un collegamento per fornire feedback: