diff --git a/Samples/CheckItem-By-Property/MainWindow.xaml b/Samples/CheckItem-By-Property/MainWindow.xaml index 46dcb78..7a7324e 100644 --- a/Samples/CheckItem-By-Property/MainWindow.xaml +++ b/Samples/CheckItem-By-Property/MainWindow.xaml @@ -17,20 +17,14 @@ - - - - - - diff --git a/Samples/CheckItem-By-Property/Model/Model.cs b/Samples/CheckItem-By-Property/Model/Model.cs index 01ba549..a3cbcec 100644 --- a/Samples/CheckItem-By-Property/Model/Model.cs +++ b/Samples/CheckItem-By-Property/Model/Model.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -7,10 +8,25 @@ namespace CheckItem_By_Property { //Model.cs - public class GroupItem + public class GroupItem : INotifyPropertyChanged { public string Name { get; set; } public string GroupName { get; set; } - public bool IsChecked { get; set; } - } + private bool enabled; + public bool Enabled + { + get { return enabled; } + set + { + enabled = value; + OnPropertyChanged("Enabled"); + } + } + + public event PropertyChangedEventHandler PropertyChanged; + protected virtual void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } } diff --git a/Samples/CheckItem-By-Property/ViewModel/ViewModel.cs b/Samples/CheckItem-By-Property/ViewModel/ViewModel.cs index 2287c79..e48029e 100644 --- a/Samples/CheckItem-By-Property/ViewModel/ViewModel.cs +++ b/Samples/CheckItem-By-Property/ViewModel/ViewModel.cs @@ -39,7 +39,7 @@ public ViewModel() GroupDescriptions = new ObservableCollection(); VirtualCollection = new ObservableCollection(); - for (int i = 0; i < 1000; i++) + for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { @@ -51,7 +51,7 @@ public ViewModel() if (i % 2 == 0) { //Define a checked state for items - myitem.IsChecked = true; + myitem.Enabled = true; } VirtualCollection.Add(myitem); }