I am exceptionally confused about how ObservableCollection and CollectionViews should be used in an MVVM application. I am NOT interested in technical explanations where you tell me how 'you're actually using CollectionView when you bind to ObservableCollection'.
I have a ListBox. The ListBox is databound to a ObservableCollection collection.
I also have a ComboBox. In the ComboBox, I have two strings: "Sort Alphabetically" and "Sort Reverse-Alphabetically". Depending on which item is selected, the logical sort action occurs. Nothing special here at all.
Now, I still have requirements. There must be NO visual side effects when the sort occurs.
For example:
- The user see "m", "n", "o" in the ListBox, he selects "n", then he sorts reverse-alphabetically.
- The user now sees "o", "n", "m". The ListBox DOES NOT scroll in any way. The user should still see "n" being selected(the SelectedItem is bound to the ViewModel and no change events should have fired).
Is what I want achievable? There is no code because I honestly don't know if CollectionView is meant to support this.
If you can just point me to a tutorial about this, that would also help(preferably one with complete code). I honestly couldn't find a tutorial about something as simple as dynamically sorting a listbox.