As a result, the changed item is no longer in the correct sort location or group. NET 3.5 or earlier, you can force a Collection View to be updated at runtime by calling its Refresh() method.Then the items will once again be properly grouped and sorted.If you are continuing from the Simple MVVM Example, I moved the Product View out of a Resource Dictionary and into a User Control to make this simpler.The last thing to do is change to make Application View and Application View Model our startup, instead of Product View/Product View Model. You can download the source code for this sample from here.It needs to contain some kind of Navigation that shows the list of Page View Models, and clicking on a Page View Model should execute the Change Page command.It also needs to contain a control to display the Current Page property, and I usually use a Content Control for that.Here is what the List Box declaration might look like: The image below depicts our List Box with grouping and sorting.You can download the sample for this post to see the complete item template, item container style, and group item style.
It usually contains This won’t compile right away because I’ve made some changes to it.
When I first started out with MVVM, I was lost about how you should navigate between pages.
I’m a firm believer in using View Models to do everything (unless it’s View-specific code), and that the UI is simply a user-friendly interface for your View Models.
I did not want to create a button on a page that has any kind of code-behind to switch pages, and I didn’t like the idea of my navigation being spread out throughout all the View Models.
I finally came to realize the solution was simple: I needed a View Model for the Application itself, which contained the application state, such as the Current Page.