Given the following XAML:
<ListView Name="UnitProperties" Grid.Column="2">
<ListView.View>
<GridView>
<GridViewColumn Header="Property">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding Path=Name}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Value">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Path=Value}" LostFocus="TextBox_LostFocus_1" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
When the TextBox loses focus, I want to get the value of the label in the first column. How do I do this via code? The Parent property of the textbox is null.
In your TextBox_LostFocus handler, you can get the value of Name property like this –