如何在VB.NET中将List(Of T)转换为ObservableCollection(Of T)? [英] How do I convert a List(Of T) to an ObservableCollection(Of T) in VB.NET?

查看:365
本文介绍了如何在VB.NET中将List(Of T)转换为ObservableCollection(Of T)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法这样做而不迭代列表,并添加项目到ObservableCollection?

Is there a way to do this without iterating through the List and adding the items to the ObservableCollection?

推荐答案

没有办法直接将列表转换为可观察的集合。您必须将每个项目添加到集合中。但是,下面是一个快捷方式,允许框架枚举值并为您添加它们。

No, there is no way to directly convert the list to an observable collection. You must add each item to the collection. However, below is a shortcut to allow the framework to enumerate the values and add them for you.

Dim list as new List(of string)
...some stuff to fill the list...
Dim observable as new ObservableCollection(of string)(list)

这篇关于如何在VB.NET中将List(Of T)转换为ObservableCollection(Of T)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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