BindingExpression.DataItem BindingExpression.DataItem BindingExpression.DataItem BindingExpression.DataItem Property

Definition

Ruft das Bindungsquellobjekt ab, das von diesem BindingExpression verwendet wird.Gets the binding source object that this BindingExpression uses.

public:
 property System::Object ^ DataItem { System::Object ^ get(); };
public object DataItem { get; }
member this.DataItem : obj
Public ReadOnly Property DataItem As Object

Eigenschaftswert

Das Bindungsquellobjekt, das von diesem BindingExpression verwendet wird.The binding source object that this BindingExpression uses.

Beispiele

Das folgende Beispiel Click zeigt die Implementierung eines-Ereignis Handlers, der die GetBindingExpression -Methode verwendet BindingExpression , um den abzurufen DataItem , und dann die-Eigenschaft aufruft, um auf das Bindungs Quell Objekt zuzugreifen.The following example shows the implementation of a Click event handler that uses the GetBindingExpression method to obtain the BindingExpression and then calls the DataItem property to access the binding source object.

Text Der TextBlock istdasBindungsZielobjekt,undseine-EigenschaftistdieBindungsZielEigenschaft.SavingsTextThe TextBlock SavingsText is the binding target object, and its Text property is the binding target property.

private void OnRentRaise(Object sender, RoutedEventArgs args)
{
  // Update bills
  System.Random random = new System.Random();
  double i = random.Next(10);
  BindingExpression bindingExpression =
    BindingOperations.GetBindingExpression(SavingsText, TextBlock.TextProperty);
  SDKSample.NetIncome sourceData = (SDKSample.NetIncome) bindingExpression.DataItem;
  sourceData.Rent = (int)((1 + i / 100) * (double)sourceData.Rent);
}
Private Sub OnRentRaise(ByVal sender As Object, ByVal args As RoutedEventArgs)
    Dim _random As New System.Random()
    Dim num1 As Double = _random.Next(10)
    Dim expression1 As BindingExpression = BindingOperations.GetBindingExpression(Me.SavingsText, TextBlock.TextProperty)
    Dim income1 As NetIncome = DirectCast(expression1.DataItem, NetIncome)
    income1.Rent = CInt(((1 + (num1 / 100)) * income1.Rent))
End Sub

Gilt für: