Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Having problem with three levels in a tree control

 
 
Old 01-13-2008   #1 (permalink)
dba


 
 

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
Old 01-15-2008   #2 (permalink)
willib


 
 

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>
>
My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
HP g95 ink levels... Vista print fax & scan
Audio levels Media Center
Ink cartridge levels Vista print fax & scan
Audio Levels Vista General
Depth Levels of File Subdirectory Tree Allowed. Vista hardware & devices


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46