I have a treeview with a HierachicalDataTemplate (shown below) bound to a datarelation in a dataset. The parent nodes represent parent parts and the children represent parts that make up the parent. In some cases the user will check the checkbox at the parent level to indicate they are replacing the entire part with all its children. At this point a textbox will appear for them to enter the new part number for the parent. So far I have that working.
What I need help with is, hiding the children when the parent checkbox is checked. I've been approaching this from the trigger path, but I can't seem to make a reference to any of the controls in the ItemTemplate from a trigger in the HierarchicalDataTemplate.Triggers. Perhaps its not possible?
<HierarchicalDataTemplate ItemsSource="{Binding MyParts}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Description}" />
<CheckBox x:Name="MyCheckBox" IsChecked="{Binding ReplaceParent}"></CheckBox>
<TextBox x:Name="NewParentPartNumberTextBox" Text="{Binding NewPartNumber}" Visibility="Collapsed"></TextBox>
</StackPanel>
<HierarchicalDataTemplate.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding ChildPartNumber}" />
<TextBox Text="{Binding NewChildPartNumber}" />
</StackPanel>
</DataTemplate>
</HierarchicalDataTemplate.ItemTemplate>
<HierarchicalDataTemplate.Triggers>
<Trigger SourceName="MyCheckBox" Property="IsChecked" Value="True">
<Setter TargetName="NewParentPartNumberTextBox" Property="Visibility" Value="Visible"/>
</Trigger>
</HierarchicalDataTemplate.Triggers>
</HierarchicalDataTemplate>