HierarchicalDataTemplate won't let me specify a datatemplate, WPF complains that control isn't a datatemplate

Hello,

I have used the treenvaigator control in a UWP app with no problem whatsoever, but in WPF it appears something is out of sync. I attempt to nest a primitives:HierarchicalDataTemplate within an ItemTemplate per the documentation, and then start defining the template directly (TextBlock, for example). This will build, but not run- the XAML parser complains that the highest level control (textblock, in this case) can't be converted to a datatemplate.

So I try to wrap it in a datatemplate, but then the HierarchicalDataTemplate complains that it's child element isn't a DependencyObject, and refuses to build.

How can I get the hierarchical functionality to work? I'm running WPF 4.6.1.

Thanks,
Eddie

1 Reply

VR Vijayalakshmi Roopkumar Syncfusion Team January 12, 2018 11:04 AM UTC

Hi Eddie

Thank you for contactin Syncfusion Support.

For the UWP SfTreeNavigator control, we suggest to use the Primitives Hierachical DataTemplate to customize the appearance of the SfTreeNavigatorItems. For the WPF SfTreeNavigator, the HierarchicalDataTemplate can be used to customize the appearance of SfTreeNavigatorItems. The same has been displayed in the following code example. 
Code:[XAML] 
 
<navigation:SfTreeNavigator ItemsSource="{Binding Models}" 
Width="300" Height="400" 
Header="Enterprise Toolkit" 
 
HorizontalAlignment="Center" 
 
VerticalAlignment="Center"> 
<navigation:SfTreeNavigator.ItemTemplate> 
 
<HierarchicalDataTemplate ItemsSource="{Binding Models}"> 
 
<StackPanel Orientation="Horizontal"> 
 
<TextBlock Text="{Binding Header}" 
 
Foreground="Green" FontWeight="Bold" 
 
VerticalAlignment="Center" Margin="18 0 0 0"/> 
 
</StackPanel> 
 
</HierarchicalDataTemplate > 
 
</navigation:SfTreeNavigator.ItemTemplate> 
</navigation:SfTreeNavigator> 
 
 
  

Please download the sample for the same from the following location:

Sample: http://www.syncfusion.com/downloads/support/forum/135429/ze/SfTreeNavigator_update-2054560689 

Regards,
Vijayalakshmi V.R.
 


Loader.
Up arrow icon