I am using MVVM Light toolkit in my WPF application. I would like to know what is the best approach for opening a new window from an existing window. I have got this MainViewModel
, which is responsible for MainWindow
of my application. Now in the MainView
, on a button click, I would like to open a second window on top of it. I have got RelayCommmand
binded to the Button
's Command
. In the RelayCommand
's method, I can create a new window object and simply call Show()
, something like this:
var view2 = new view2()
view2.Show()
but I don't think the ViewModel should be responsible for creating the new view2
object. I have read this post WPF MVVM Get Parent from VIEW MODEL where Bugnion has suggested to pass message to the view1
from the viewmodel1
and then view1
should create the new view2
. But I am not sure what does he actually mean by passing the message to the view1
? How should the view1
handle the message? In it's code behind or what?
Regards, Nabeel
See Question&Answers more detail:os