开发者

How do I load a treeview From RIA

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 th开发者_开发知识库e data to its parent nodes through opject children type of scenario...


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

  • How to: Use a TreeView to Display Hierarchical Data
  • Silverlight Toolkit – Using Silverlight TreeView Control


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜