View Single Post
Old 01-13-2008   #1 (permalink)
dba
Guest


 

Having problem with three levels in a tree control

I've seen many posts on this problem but haven't found a solution yet.
Any help would be greatly regarded. My data source is an xml file that
looks like this.

<?xml version="1.0" encoding="UTF-8"?>
<DataLibrary version="0.1" >
<Family><FamilyID>1</FamilyID><Name>ACTIVITY</
Name><SubFamily><SubFamilyID>1</SubFamilyID><Name>ACTION</
Name><LibraryItem><DataItemID>1</DataItemID><Name>ACTION</
Name><Example></Example><Qualifier>STATIC</Qualifier><DataType>TEXT</
DataType><DataEntryType>RESTRICTED </DataEntryType><Client>X</
Client><Company>X</Company><Iqor>X</Iqor><Employee></
Employee><Vendor></Vendor><Publisher>Call</Publisher><Subscriber></
Subscriber></LibraryItem>
<LibraryItem><DataItemID>2</DataItemID><Name>SUB-ACTION</
Name><Example></Example><Qualifier>STATIC</Qualifier><DataType>TEXT</
DataType><DataEntryType>RESTRICTED </DataEntryType><Client>X</
Client><Company>X</Company><Iqor>X</Iqor><Employee></
Employee><Vendor></Vendor><Publisher>Attended</Publisher><Subscriber></
Subscriber></LibraryItem>
</SubFamily>
</Family>

My XAML looks like this:


<Window.Resources>
<HierarchicalDataTemplate x:Key="ht1" DataType="Family"
ItemsSource="{Binding XPath=DataLibrary/Family/Name}">
<TextBlock FontWeight="Bold" FontSize="20" Text="{Binding
XPath=Name}" />
</HierarchicalDataTemplate>
<HierarchicalDataTemplate x:Key="ht2" DataType = "SubFamily"
ItemsSource="{Binding XPath=DataLibrary/Family/SubFamily/Name}">
<TextBlock FontWeight="Bold" FontSize="20" Text="{Binding
XPath=Name}" />
</HierarchicalDataTemplate>
<DataTemplate DataType="LibraryItem" >
<TextBlock FontStyle="Italic" Text="{Binding XPath=Name}" /
Quote:

>
</DataTemplate>
<XmlDataProvider x:Key="LI" Source="DataLibrary.xml" />
</Window.Resources>
<StackPanel>
<TreeView>
<TreeViewItem ItemsSource="{Binding Source={StaticResource
LI}, XPath=DataLibrary}" Header="Data Library" />
</TreeView>
</StackPanel>

My System SpecsSystem Spec