views:

35

answers:

2

I have a TreeView I want to populate it from RIA Entity Queries. Is this possible

I have 4 Tiers.

Each Table has

ID    Description   ParentID
x1     pdq
x2     pdq
x3     pdq

y1     ABC           x1
y2     ABd           x1
y3     add           x2   
y4     ade           x3

I want the data to be able to have this format.

How do i go about this. and have it load to my tree view properly. Without going through and assign all of the data to its parent nodes through opject children type of scenario...

+1  A: 

You should look at the HierarchicalDataTemplate. See the links below for some examples:

Obalix
+1  A: 

You don't have to go through and assign children if the entities are already related in the model. Simply retrieve the entities Include-ing all the children, and use a HierarchicalDataTemplate to display them. Entity Framework will take care of setting the correct children.

Alternatively, if the relationship between children and parents isn't defined by a foreign key, you can use a few simple linq queries or a helper class, but the actions behind will still be to walk the collection adding the children to the parents. I'll add a sample in a few hours when I get to work, if you're still interested.

Alex Paven
Awesome explaination, Thanks I assume the links to look at are the same as the ones in Obalix Explaination...
Rico
For the method of binding to the controls, yes, exactly, HierarchicalDataTemplate is the way to go.
Alex Paven