I am trying to select/unselect all the listview items when checkbox in listview header is clicked.
View (xaml):
Your class DataModel must implement INotifyPropertyChanged
, and fire the PropertyChanged
event when the IsSelected
property changes. Otherwise, the Binding of the ListViewItem's IsSelected
property isn't notified.
public class DataModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private bool isSelected;
public bool IsSelected
{
get { return isSelected; }
set
{
isSelected = value;
PropertyChanged?.Invoke(this,
new PropertyChangedEventArgs(nameof(IsSelected)));
}
}
public string ID { get; set; }
public string Desc { get; set; }
}