tags:

views:

278

answers:

2

when using mvvm pattern, when we have lists we use ObservableCollection<>.

my question is when should i call to

CollectionViewSource.GetDefualtView(theCollection);

to get the view that i can filter and sort and do some other cool stuff.

if i dont work with mvvm i'll do it in window.load

A: 

For MVVM is better use a ViewModel with property of type ObservableCollection. In this viewmodel you can implement your functionality.

Rangel
yea ok and how should i perform filtering and sorting????ObservableCollection does not have those capabilities, IListCollectionView has them.
Chen Kinnrot
You can use OrderBy extesions methods.
Rangel
why should i touch my collection when the collectionview can order itself?
Chen Kinnrot
what about filtering, i don't think you should mass up your collection
Chen Kinnrot
A: 

just need to make sure that you call the

CollectionViewSource.GetDefualtView([your observable collection])

after the collection reference initiated...

and dont call it more than once cause there is no reason

Chen Kinnrot