Should I bind to ICollectionView or ObservableCollection

前端 未结 5 618
失恋的感觉
失恋的感觉 2020-11-29 19:44

Should one bind DataGrid to the

ICollectionView = CollectionViewSource.GetDefaultView(collection)

or to the

Observabl

5条回答
  •  醉话见心
    2020-11-29 20:25

    Just to add to what Jon said. The main difference is, that by using CollectionViewSource.GetDefaultView(collection), you are making you ViewModel dependent on WPF. Many MVVM purists don't like this and this would leave ObservableCollection only valid option.

    Other option would be to use ICollectionView and use a class, that implement it, but is not part of WPF itself.

提交回复
热议问题