title: Opening new window in MVVM WPF
body: <p>I have a Button and I bind this button to a command in ViewModel say <code>OpenWindowCommand</code>. When I click on the button I want to open a new window. But creating a window instance and showing a window from view model is a violation of MVVM. I have created interface like</p>
  
  <pre><code>interface IWindowService
  {
      void showWindow(object dataContext);
  }
  </code></pre>
  
  <p>and <code>WindowService</code> implements this interface like</p>
  
  <pre><code>class WindowService : IWindowService
  {
      public void showWindow(object dataContext)
      {
          ChildWindow window=new ChildWindow();
          window.DataContext=dataContext;
          window.Show();
      }
  }
  </code></pre>
  
  <p>In this class I have specified <code>ChildWindow</code>. So this class is tightly coupled with showing <code>ChildWindow</code>. When I want to show another window, I have to implement another class with the same interface and logic. How can I make this class generic so that I can just pass an instance of any window and the class will be able to open any window?</p>
  
  <p>I am not using any built MVVM frameworks. I have read many articles on StackOverflow but I could not found any solution for this.</p>