Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Store Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems.

Go Back   Vista Forums > Vista technology newsgroups > Avalon

Having problem with three levels in a tree control

Reply
 
Thread Tools Display Modes
Old 01-13-2008   #1 (permalink)
dba
Guest
 
Posts: n/a

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>

  Reply With Quote

Old 01-15-2008   #2 (permalink)
willib
Guest
 
Posts: n/a

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>
>
  Reply With Quote
 
Reply

Thread Tools
Display Modes









Vistax64.com 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 2005-2008

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