i made check box in wpf ,Got it from Internet.I want to see which item is checked or unchecked.Any idea how to do this
here goes the code
Class
public class CheckedListItem
{
public int Id { get; set; }
public string Name { get; set; }
public bool IsChecked { get; set; }
public string Email { get; set; }
}
Usage
List<CheckedListItem> AvailablePresentationObjects = new List<CheckedListItem>();
CheckedListItem item = new CheckedListItem();
for (int i = 0; i < 10; i++)
{
item = new CheckedListItem();
item.Id = i;
item.Name = i.ToString();
item.IsChecked = false;
AvailablePresentationObjects.Add(item);
}
list.ItemsSource = AvailablePresentationObjects;
XMAL
<ListBox x:Name="list" Margin="3,277,0,0" Height="234" VerticalAlignment="Top" Selec
tionMode="Extended">
<ListBox.ItemTemplate>
<HierarchicalDataTemplate>
<my:RibbonCheckBox Label="{Binding Name}" IsChecked="{Binding IsChecked}" />
</HierarchicalDataTemplate>
</ListBox.ItemTemplate>
</ListBox>
took it from Here
Checked ListBox
Question is
How to implement property change so
that i can know which item was checked
and which was unchecked
You can get collection of selected items:
list.SelectedItems.Each item you can cast to
CheckedListItemand check that item is checked.If you want to handle property changing, you should implement interface
INotifyPropertyChangedinCheckedListItemclassExample of INotifyPropertyChanged:
Add this to your class and call
OnPropertyChangedin properties: