View Single Post
Old 01-15-2008   #2 (permalink)
willib
Guest


 

Re: Having problem with three levels in a tree control

Hello Bryan,

you may try to change the following lines:

<HierarchicalDataTemplate DataType="Family" ItemsSource="{Binding
XPath=./SubFamily}" >
<TextBlock FontWeight="Bold" FontSize="20" Text="{Binding
XPath=Name}" />
</HierarchicalDataTemplate>

<HierarchicalDataTemplate DataType = "SubFamily" ItemsSource="{Binding
XPath=./LibraryItem}">
<TextBlock FontWeight="Bold" FontSize="20" Text="{Binding
XPath=Name}" />
</HierarchicalDataTemplate>


<TreeViewItem ItemsSource="{Binding Source={StaticResource LI},
XPath=DataLibrary/Family}"
Header="Data Library" />



WilliB


"dba" <bryanmurtha@xxxxxx> schrieb im Newsbeitrag
news:4ab41b22-1d03-44a7-a860-3377908f6f01@xxxxxx
Quote:

> 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>
>