BindingExpression.DataItem Property

 

Gets the binding source object that this BindingExpression uses.

Namespace:   System.Windows.Data
Assembly:  PresentationFramework (in PresentationFramework.dll)

Public ReadOnly Property DataItem As Object

Property Value

Type: System.Object

The binding source object that this BindingExpression uses.

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.

The TextBlock SavingsText is the binding target object, and its Text property is the binding target property.

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

.NET Framework
Available since 3.0
Silverlight
Available since 3.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show: