How do I convert a List(Of T) to an ObservableCollection(Of T) in VB.NET?

前端 未结 6 2049
暗喜
暗喜 2020-12-31 01:33

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

6条回答
  •  天命终不由人
    2020-12-31 02:12

    to clarify what Junior is saying (with an added example if you're using LINQ that returns an IEnumerable):

    //Applications is an Observable Collection of Application in this example
    List filteredApplications = 
          (Applications.Where( i => i.someBooleanDetail )).ToList();
    Applications = new ObservableCollection( filteredApplications );
    

提交回复
热议问题