This question is in reference to this link Opening new window in MVVM WPF.
I want to open new window in some service.
Following is my code
This is a window service which I am calling from ViewModel
public class WindowService : IWindowService
{
public void ShowWindow(object viewModel)
{
var win = new Window {Content = viewModel};
win.Show();
}
}
Following is my App.xaml code
<DataTemplate DataType="{x:Type viewModel:MainViewModel}" >
<viewModel:ChildWindow />
</DataTemplate>
Now this works fine for all windows which have different ViewModel. But when I want to open another window which is using same view model but their view is not same,I can not define data template of same type in App.xaml.
How do I open multiple new window which have same ViewModel? Should I create different ViewModel for each window?