I am using C#, .Net WPF and MVVM approach
What would be a recommended strategy/Design for the situation were I have a MainWindow view and associated viewmodel and wish to "open" another such window for the user which will display another objects values. For example they are viewing an objects values via mainwindow then go into a search feature where they find another object for which they want to view its values. they click on this in the list and a view appears showing that objects values. they then can close this view and return to the original view with the original object.
First I have at least 2 choices Im aware of I can begin with. Use the existing MainWindow view and viewmodel for the new object as they are exactly the same or 99% same and need to use same view/viewmodel functionality or write a (almost) copy of the mainwindow view/viewmodel and show this one. The second option will require more maintenance because I have to duplicate any changes across both but can make other things easier and maybe cleaner.
So whats best approach for this issue?
The next decision to make is how to do this? I have so far considered the following ways to do the "showing" of the new view and selected objects data.;
1. set up datatemplates in the mainwindow and swap the views in and out (ie triggered by xaml button command bound to viewmodel)
2. instantiate a new instance of MainWindow view and mainwindowviewmodel using .ShowDialog in code (ie triggered by xaml button command bound to viewmodel)
4. Set up a view factory instead of instantiating in code
In all cases I need to pass a parameter to the newly shown View or Dialog that is used by its ViewModel to retrieve from database and show the required object.