So i've been reading/watching lots about MVVM and pretty much got my head around the concept but still struggling a little with the practical implementation side of it.
I have read that a benefit of MVVM is that it makes testing easier: You can have two views (an presumably two view-models) for one Model. So perhaps a POS/Till system with a view where you can add products to an invoice and then another view to test the functionality which shows the contents of various datatables in a datagrid.
Is this a reasonable use case and scenario?
If the above is correct, the next question is with respect to how this all works in visual studio.
Again please correct me if I am wrong, but as I understand it the MainWindow.xaml is your default view, the MainWindow.xaml.cs is your Model and then you create a new class MainWindowViewModel.cs for the view model. All good so far, aside from the fact that VS likes to link the view and the model together. - You cannot create a new page or window without VS creating a .xaml.cs 'model' file to go with it. So what should I do in the above example where I would like to have multiple views to a model for testing purposes or whatever. Do I just leave the additional .xaml.cs files blank for each additional view for the same model? or can I safely delete them ? Or do I need them to some how link them to the 'base' model?
Lastly, Is MVVM a sensible approach for developing a largish WPF application? As an individual programmer who will be working on all aspects of the program (view, model and view model) is there enough benefits of MVVM to make it worth applying at all or am I wasting my time writing a load of extra code which wont really be useful unless used in a large team/corporate environment where different people or teams would be collaborating on different elements of the program?
I have read that a benefit of MVVM is that it makes testing easier: You can have two views (an presumably two view-models) for one Model. So perhaps a POS/Till system with a view where you can add products to an invoice and then another view to test the functionality which shows the contents of various datatables in a datagrid.
Is this a reasonable use case and scenario?
If the above is correct, the next question is with respect to how this all works in visual studio.
Again please correct me if I am wrong, but as I understand it the MainWindow.xaml is your default view, the MainWindow.xaml.cs is your Model and then you create a new class MainWindowViewModel.cs for the view model. All good so far, aside from the fact that VS likes to link the view and the model together. - You cannot create a new page or window without VS creating a .xaml.cs 'model' file to go with it. So what should I do in the above example where I would like to have multiple views to a model for testing purposes or whatever. Do I just leave the additional .xaml.cs files blank for each additional view for the same model? or can I safely delete them ? Or do I need them to some how link them to the 'base' model?
Lastly, Is MVVM a sensible approach for developing a largish WPF application? As an individual programmer who will be working on all aspects of the program (view, model and view model) is there enough benefits of MVVM to make it worth applying at all or am I wasting my time writing a load of extra code which wont really be useful unless used in a large team/corporate environment where different people or teams would be collaborating on different elements of the program?