转换名单,其中最好的办法;对象>到的ObservableCollection<对象> [英] The best way to convert List<Object> to ObservableCollection<Object>

查看:184
本文介绍了转换名单,其中最好的办法;对象>到的ObservableCollection<对象>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有名单,其中,对象> 其中对象有很多孩子的的名单,其中,对象> 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

这篇关于转换名单,其中最好的办法;对象&gt;到的ObservableCollection&LT;对象&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆