am having a set of checkbox in a stackpanel, i want to get the selected checkbox in my code..
how i can get those selected checkbox in a stackpanel
am having a set of checkbox in a stackpanel, i want to get the selected checkbox in my code..
how i can get those selected checkbox in a stackpanel
You can query the children of the stackpanel.
IEnumerable<CheckBox> selectedBoxes =
from checkbox in this.stackPanel1.Children.OfType<CheckBox>()
where checkbox.IsChecked.Value
select checkbox;
foreach (CheckBox box in selectedBoxes)
{
// do something
}
Same query in lambda form
IEnumerable<CheckBox> selectedBoxes =
this.stackPanel1.Children.OfType<CheckBox>()
.Where(cb => cb.IsChecked.Value);