Union two ObservableCollection Lists

前端 未结 2 617
北海茫月
北海茫月 2021-02-08 16:34

I have two ObservableCollection lists, that i want to unite. My naive approach was to use the Union - Method:

ObservableCollection unitedPoints = ob         


        
2条回答
  •  旧时难觅i
    2021-02-08 17:18

    Do you want to merge the existing contents, but then basically have independent lists? If so, that's relatively easy:

    ObservableCollection unitedPoints = new ObservableCollection
        (observableCollection1.Union(observableCollection2).ToList());
    

    However, if you want one observable collection which is effectively a "view" on others, I'm not sure the best way to do that...

提交回复
热议问题