Hello,
I'm trying to create a multicolumn TreeView showing
multiple properties of a complex object, but if I set the ItemsSource in
code, for some reason the child nodes of nodes are not detected, so
there is no expander to expand the subitems (which have the same type as
the parent object, so it's like a nested folder structure). Setting the
TreeViewItemAdv collection in the XAML works fine.
Here's the XAML:
<Window x:Class="MultiColumnTreeViewAdvSample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MultiColumnTreeViewAdvSample"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
Title="MainWindow" Height="350" Width="740">
<Window.Resources>
<Style TargetType="{x:Type syncfusion:TreeViewItemAdv}">
<Setter Property="IsExpanded" Value="True"/>
</Style>
</Window.Resources>
<Grid>
<!-- Adding TreeViewAdv with Enabling multiple column -->
<syncfusion:TreeViewAdv x:Name="treeViewAdv" MultiColumnEnable="True">
<!-- Adding TreeViewItemAdv -->
<!-- Setting the TreeViewItemAdv collection here works, but if this
is commented out, and the collection is filled in code, childnodes are
not detected -->
<!--<syncfusion:TreeViewItemAdv Tag="1" Name="treeViewItemAdv" Header="Marital Status">
<syncfusion:TreeViewItemAdv Tag="11" Header="Single" />
<syncfusion:TreeViewItemAdv Tag="12" Header="Married"/>
<syncfusion:TreeViewItemAdv Tag="13" Header="Married with Children"/>
</syncfusion:TreeViewItemAdv>
<syncfusion:TreeViewItemAdv Tag="2" Header="Baby Vaccines">
<syncfusion:TreeViewItemAdv Tag="21" Header="Hepatitis B"/>
<syncfusion:TreeViewItemAdv Tag="22" Header="Tetanus"/>
<syncfusion:TreeViewItemAdv Tag="23" Header="Polio"/>
<syncfusion:TreeViewItemAdv Tag="24" Header="Measles"/>
</syncfusion:TreeViewItemAdv >
<syncfusion:TreeViewItemAdv Tag="3" Header="Country Information">
<syncfusion:TreeViewItemAdv Tag="31" Header="Canada"/>
<syncfusion:TreeViewItemAdv Tag="32" Header="France"/>
<syncfusion:TreeViewItemAdv Tag="33" Header="Germany"/>
<syncfusion:TreeViewItemAdv Tag="34" Header="UK"/>
<syncfusion:TreeViewItemAdv Tag="35" Header="USA"/>
</syncfusion:TreeViewItemAdv>-->
<!-- Adding header -->
<syncfusion:TreeViewAdv.Columns>
<syncfusion:TreeViewColumnCollection>
<syncfusion:TreeViewColumn Width="400" Header="Name"/>
<syncfusion:TreeViewColumn Width="150" Header="Description"/>
<syncfusion:TreeViewColumn Width="150" Header="IsValid"/>
</syncfusion:TreeViewColumnCollection>
</syncfusion:TreeViewAdv.Columns>
</syncfusion:TreeViewAdv>
</Grid>
</Window>
I tried creating TreeViewItemAdv instances with the DataContext set to my ComplexObject (rather than a collection of ComplexObject's), but that didn't seem to help. What am I missing here?
Attachment:
MultiColumnTreeViewAdvSample_489e08c8.zip