Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->public void checkAll_Click(object sender, RoutedEventArgs e) //checkAll is my button
{
var objects = GetChilds(MyTreeview).OfType<CheckBox>();
foreach (CheckBox d in objects)
{
d.IsChecked = true;
}
}
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> private static IEnumerable<DependencyObject> GetChilds(DependencyObject root)
{
List<DependencyObject> lst = new List<DependencyObject>();
lst.Add(root);
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(root); i++)
lst.AddRange(GetChilds(VisualTreeHelper.GetChild(root, i)));
return lst;
}
http://www.cnblogs.com/z_lb/articles/1673415.html