My tree definition is:
<TreeView Name="tree" ItemsSource="{Binding Children}" >
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
<CheckBox Name="foo"></CheckBox>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
Having a TreeViewItem element, I try to find corresponding CheckBox, but
tree.Template.FindName("foo", item);
throws
[System.InvalidOperationException] = {"This operation is valid only on elements that have this template applied."}
And
item.Template.FindName("foo", item)
gives me null. What is a right solution?