title: open child window inside a parent window in wpf using MVVM
body: <p>I have a window called "DashBoard" window. This window appears after user sucessfully logs in. Now I wanted to open child window called "Memberlist"inside the Dashboard when user select an option from menu item. User should not be able to pullout "Memberlist" window from "Dashboard" window. </p>
  
  <h2>DashboardView.xmal (Parent Window)</h2>
  
  <pre><code>&lt;Window x:Class="MyProject.DashboardView"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="My Project: Dashboard" Height="600" Width="800" WindowState="Maximized"    
      WindowStartupLocation="CenterOwner"&gt;
      &lt;Grid&gt;
      &lt;Menu Height="23" HorizontalAlignment="Left" Name="menu1" VerticalAlignment="Top" 
  Width="44"&gt;
          &lt;MenuItem Header="_File" &gt;
              &lt;MenuItem Header="View Memberlist…" Command="{Binding 
  Path=DisplayMemberlistCommand}" /&gt;
  &lt;/MenuItem&gt;
  &lt;/Menu&gt;
  &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <h2>MemberlistView.xaml (Child Window)</h2>
  
  <pre><code>&lt;Window x:Class="MyProject.MemberlistView"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:toolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="View Memberlist" Height="400" Width="806"&gt;
  &lt;Grid&gt;
      &lt;Grid Height="383" Width="1179"&gt;
       &lt;toolkit:DataGrid x:Name="dgMemberlist" 
                        ItemsSource="{Binding Path=MemberList}"
                        AutoGenerateColumns="False" Margin="21,57,422,106"
                        SelectedItem="{Binding Path=SelectedMemberItem, 
  UpdateSourceTrigger=PropertyChanged}"&gt;
              &lt;toolkit:DataGrid.Columns&gt; 
                  &lt;toolkit:DataGridTextColumn Header="Export ID" Width="100"   
  Binding="{Binding MemberfullName}" IsReadOnly="True" /&gt;
  
   &lt;/toolkit:DataGrid.Columns&gt;
          &lt;/toolkit:DataGrid&gt;
  
  &lt;/Grid&gt;
   &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <h2>DashboardViewModel.cs</h2>
  
  <pre><code>private ICommand _displayMemberlistCommand;
  public ICommand DisplayMemberlistCommand
      {
          get
          {
              if (_displayMemberlistCommand == null)
                  _displayMemberlistCommand = new RelayCommand(a=&gt;DoDisplayMemberlist(), 
  p=&gt;true);
              return _displayMemberlistCommand;
          }
          set
          {
              _displayMemberlistCommand = value;
          }
      }
  
  
          private void DoDisplayMemberlist() 
          {
              DashboardView dv = new DashboardView();
              MemberlistView mlWindow = new MemberlistView ();
              mlWindow.Owner = Application.Current.MainWindow;
              mlWindow .Show();
          }
  </code></pre>