I working with WPF application and using MVVM pattern for that. I'm having two separate project for view and viewmodel.
Added reference of Unity
in view and I'm using Unity
to inject my instance of MainWindowViewModel
to MainWindow
view on StartUp
of app and able to bind the viewmodel to view.
Now, I want to open the new instance of MainWindow
on clicking the button on the MainWindow
view.
Problem is how to create the an instance of view from Viewmodel.
Already tried the following:
EDIT:
To answer Wills questions
- I want to achieve this without any addons or plugins as I'm not familiar with any of those and most of the answers refering to some addons. Also, I feel it will be really handy for me if I make it work myself that gives me full control over it.
- I tried this but unable to make it work. Also, it was not clear on where i have to put what (either in view or vm)
- I don't want to open multiple
MainWindow
, this is just a R&D for the another work. In real scenario, we need to show status of some device attached with the systems and there will be separateWindow
for each device attached. Even, if we can open mutiple childwindow fromMainwindow
, I'm ok with that. - I just want to open multiple instance of window with different datacontext instance, It can be either from view or vm but it should maintain MVVM.