i have listview with checkboxes. But sometimes, when i check checkbox all others checkboxes checked earlier uncheck, but cant find, where is the problem.
Will be gratefull for any help.
Here is XAML code:
<ListView ItemsSource="{Binding SeatCars}" SelectionChanged="SeatSelectionChanged">
<ListView.ItemTemplate>
<DataTemplate>
<CheckBox Content="{Binding}" IsChecked="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListViewItem}}, Path=IsSelected}"></CheckBox>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Here is EventHandler: But problem persists event without eventhandler.
private void SeatSelectionChanged(object sender, SelectionChangedEventArgs e)
{
foreach (var item in e.AddedItems)
{
MainViewModel.SeatSelected.Add(item.ToString());
}
foreach (var item in e.RemovedItems)
{
MainViewModel.SeatSelected.Remove(item.ToString());
}
}
Aucun commentaire:
Enregistrer un commentaire