I’m implementing my first WPF application using the MVVM pattern.
According to the tutorial I’m following, it is a bad practice to have code in your code behind class.
Now I want to implement sorting of a GridView when you click on a column header.
The usual way to achieve this, is implementing a column click handler in your code behind class, which seems to be a code smell (see above).
Is there a solution without using the code behind class?
One way I can think of is to provide a SortCommand : ICommand in my viewmodel that does the sorting in the model. But I’m not sure if this is a good and clean solution.
Thanks for any help
I would use the command approach.
Remember that the Model is your data, the ViewModel is an adaptor which makes the data available to the View, and the View is your GUI.