It seems that you are using the HierarchicalDataTemplate in your XAML code for TreeView . Replacing XAML with the appropriate C # code will help. We can set the attached property DataTemplateExtensions.Hierarchy in the code-at-end in the Loaded event for the TreeView , for example:
<controls:TreeView x:Name="treeView" Loaded="treeView_Loaded" ...
And in encoding:
private void treeView_Loaded(object sender, RoutedEventArgs e) {
source share