I have a C#, WPF ListView that has checkbox and a string in each row. When I click the checkbox, I want it be able to get the sibling string that is in the same row but I don’t quite know how. I’m a WPF noob.
I have my columns bound to the properties of an incoming object called Row that has a Name and a boolean that indicates whether or not it is active.
It’s almost like I need to walk up the visual tree to get the “row” and then grab the child that is not a checkbox.
Any suggestions are greatly appreciated. XAML below.
mj
<ListView Name="CompanyListView" Width="300" Height="200">
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Width="25">
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding Path=Active}" Click="CompanyCheckboxClicked"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=Name}" Width="250"/>
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>
The CheckBox’s DataContext should contain the Row object.