How do I get CheckBox.Checked item, my checkbox is inside listBox and listbox is binded with a class.
My class has two items: Name
and Id
My code below:
I want that when I check on checkbox, in the background, I want Id of checked item.
private void CheckBox1_Checked(object sender, RoutedEventArgs e)
{
ListBoxItem checedItem = this.listBox1.ItemContainerGenerator.ContainerFromItem((sender as CheckBox).DataContext) as ListBoxItem;
if (checedItem != null)
{
checedItem.IsSelected = true;
}
}