Hi,
I have a TreeView whose contents (nested TreeViewItems) are generated from a dataset via databinding, which all seems to work fine. The issue I'm running into is that when I try and manipulate the contents of the TreeViewItem headers in code, the Header property returns the DataRowView that the TreeViewItem was generated from and not, as I was expecting, the control generated by the template.
Here's an example of the template I'm using to generate the TreeViewItems:
<DataTemplate x:Key="seasonTreeViewItemTemplate">
<TreeViewItem>
<TreeViewItem.Header>
<CheckBox Content="{Binding Path=Row.SeasonID}" Tag="{Binding}" ToolTip="{Binding Path=Row.Title}" IsEnabled="{StaticResource seasonPermitted}" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked" />
</TreeViewItem.Header>
<TreeViewItem Header="Championships" ItemTemplate="{StaticResource championshipTreeViewItemTemplate}">
<TreeViewItem.ItemsSource>
<Binding Path="Row" ConverterParameter="FK_Championship_Season">
<Binding.Converter>
<local:RowChildrenConverter />
</Binding.Converter>
</Binding>
</TreeViewItem.ItemsSource>
</TreeViewItem>
</TreeViewItem>
</DataTemplate>
Can anyone point out where I'm going wrong and advise me how to access the header checkboxes (ideally without delving into the VisualTree if possible)?
Thanks, James