转换名单,其中最好的办法;对象>到的ObservableCollection<对象>对象、最好的、名单、办法

2023-09-04 01:54:48 作者:汝等皆为龙套

我有名单,其中,对象> 其中对象有很多孩子的的名单,其中,对象> 4-6左右的水平。

I have got List<Object> where the Object has a lot of childs List<Object> around 4-6 levels.

现在我必须将其绑定到WPF树视图...:(

Now I have to bind it to WPF TreeView... :(

其中最好的办法将其转换成的ObservableCollection&LT;对象&gt;

推荐答案

答案的一部分是使用无功扩展(Rx)的。您可以从的NuGet得到它,它是由微软公司开发的。有了它的帮助,您可以简单地说: myListCollection.ToObservable();

One part of the answer is to use Reactive Extensions (Rx). You can get it from NuGet and it's developed by Microsoft. With the help of it you can simply say: myListCollection.ToObservable();

如果您的孩子收集始终是你可以用相同名称的节点而(item.Collection!= NULL || item.Collection.Count == 0),把 ToObservable()循环内

If your child collections always are in a node with the same name you could use a while(item.Collection != null || item.Collection.Count == 0) and put the ToObservable() within the loop

 
精彩推荐
图片推荐