TemplateContainerAttribute.BindingDirection Właściwość
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Pobiera kierunek powiązania kontrolki kontenera.
public:
property System::ComponentModel::BindingDirection BindingDirection { System::ComponentModel::BindingDirection get(); };
public System.ComponentModel.BindingDirection BindingDirection { get; }
member this.BindingDirection : System.ComponentModel.BindingDirection
Public ReadOnly Property BindingDirection As BindingDirection
Wartość właściwości
Element BindingDirection wskazujący kierunek powiązania kontrolki kontenera. Wartość domyślna to OneWay.
Przykłady
W poniższym przykładzie kodu pokazano, jak utworzyć szablonową kontrolkę o nazwie TemplatedFirstControl
i skojarzyć ją z kontenerem o nazwie FirstTemplateContainer
. Umożliwia to tworzenie kontrolek niestandardowych, które wyświetlają czas serwera, gdy szablon nie jest określony, oraz zawartość szablonu po określeniu szablonu. Metoda GetCustomAttribute określa BindingDirection właściwość FirstTemplate
właściwości .TemplateFirstControl
Ten przykład kodu jest częścią większego przykładu udostępnionego TemplateContainerAttribute dla klasy .
// Get the class type for which to access metadata.
Type clsType = typeof(TemplatedFirstControl);
// Get the PropertyInfo object for FirstTemplate.
PropertyInfo pInfo = clsType.GetProperty("FirstTemplate");
// See if the TemplateContainer attribute is defined for this property.
bool isDef = Attribute.IsDefined(pInfo, typeof(TemplateContainerAttribute));
// Display the result if the attribute exists.
if (isDef)
{
TemplateContainerAttribute tca =
(TemplateContainerAttribute)Attribute.GetCustomAttribute(pInfo, typeof(TemplateContainerAttribute));
Response.Write("The binding direction is: " + tca.BindingDirection.ToString());
}
' Get the class type for which to access metadata.
Dim clsType As Type = GetType(VB_TemplatedFirstControl)
' Get the PropertyInfo object for FirstTemplate.
Dim pInfo As PropertyInfo = clsType.GetProperty("FirstTemplate")
' See if the TemplateContainer attribute is defined for this property.
Dim isDef As Boolean = Attribute.IsDefined(pInfo, GetType(TemplateContainerAttribute))
' Display the result if the attribute exists.
If isDef Then
Dim tca As TemplateContainerAttribute = CType(Attribute.GetCustomAttribute(pInfo, GetType(TemplateContainerAttribute)), TemplateContainerAttribute)
Response.Write("The binding direction is: " & tca.BindingDirection.ToString())
End If
Uwagi
Właściwość BindingDirection może być polem OneWay , w którym szablon może akceptować tylko wartości właściwości lub TwoWay pole, w którym szablon może akceptować i uwidaczniać wartości właściwości. W tym ostatnim scenariuszu kontrolki powiązane z danymi automatycznie mogą używać operacji aktualizacji, usuwania i wstawiania źródła danych przy użyciu Bind
składni powiązania danych.
Aby uzyskać więcej informacji na temat powiązania danych, zobacz Binding to Databases and Data-Binding Expressions Overview (Wiązanie z bazami danych i wyrażeniami powiązania danych — omówienie).