WPF ListView SelectedItem is null
Posted
by ozczecho
on Stack Overflow
See other posts from Stack Overflow
or by ozczecho
Published on 2010-04-09T14:17:22Z
Indexed on
2010/04/09
14:43 UTC
Read the original article
Hit count: 966
Hi All
I have a Listview that has a checkbox as one of the columns. If I click anywhere but the actual checkbox the SelectedItem of the ListView is set to the current selected row, as expected. If, on the other hand I click onto the checkbox (without clicking on the row first) then the SelectedItem is null or the previously clicked row.
Can anyone help me out....
Cheers
<ListView Width="auto" SelectionMode="Single" x:Name="listBox" ItemsSource="{Binding MyData}" SelectedItem="{Binding Path=SelectedMyData}">
<ListView.View>
<GridView>
<GridViewColumn Header="Date" Width="120">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ContentPresenter Style="{StaticResource DateTimeContent}" Content="{Binding MyDate}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox IsThreeState="False"
Checked="OnChkChecked"
Unchecked="OnChkChecked"
IsChecked="{Binding IsCorrect}"></CheckBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
© Stack Overflow or respective owner