How to cast a List to an ObservableCollection in wpf?

后端 未结 4 1949
暖寄归人
暖寄归人 2021-02-05 11:09

I am in wpf, and have a generic list: List. Now I wish to cast it to a generic observable collections: ObservableCollection.

I understand I can iterate over the list and

4条回答
  •  太阳男子
    2021-02-05 11:44

    If you JUST want to create an ObservableCollection from a List, then all you need to do is

    ObservableCollection obsCollection = new ObservableCollection(myList);
    

提交回复
热议问题