我需要一个ObservableCollection树级别

时间:2010-11-09 22:39:48

标签: c#-4.0

我需要创建一个ObservableCollection<>对于树o在c#中有更多级别,如下所示:

  • 第1组
  • 第2组
    • 第1组
    • 第2组
      • 第1组
      • 第2组
    • 第3组

提前感谢,

蒂姆伦纳德

1 个答案:

答案 0 :(得分:0)

创建一个“node”类,其中包含一个可观察的子节点集合,如下所示:

class node
{
// add some data properties in here, too

   public ObservableCollection<node> children;
}


// declare an instance, in the data model (or where-ever)
ObservableCollection<node> RootLevel = new ObservableCollection<node>();
如果我知道你试图做什么平台,我可能会给你一个更好的答案。 (WPF或Silverlight等)