title: MvvmCross WPF - Multi-window application (MvxWindow)
body: <p>I have verified a lot of samples 'how to' create WPF apps using MvvmCross framework. But there is no showing how to create a multi-window application.</p>
  
  <p>How can I create and show independent window with own ViewModel?</p>
  
  <p>My project files looks like:</p>
  
  <p>MainWindow.xaml => MainWindow.xaml.cs</p>
  
  <pre><code>public partial class MainWindow : MvxWindow
  {
      public MainWindow()
      {
          InitializeComponent();
      }
  }
  </code></pre>
  
  <p>LoginPageView.xaml => LoginPageView.xaml.cs</p>
  
  <pre><code>public partial class LoginPageView : MvxWpfView
  {
      public LoginPageView()
      {
          InitializeComponent();
      }
  }
  </code></pre>
  
  <p>MenuPageView.xaml => MenuPageView.xaml.cs</p>
  
  <pre><code>public partial class MenuPageView : MvxWindow // &lt;-- I want use UserControl (MvxWpfView), and Window (MvxWindow)
  {
      public MenuPageView()
      {
          InitializeComponent();
      }
  }
  </code></pre>
  
  <p>When I use MvxWindow class for MenuPageView, there is exception such as below.</p>
  
  <pre><code>mvx: Diagnostic: 11,83 Showing ViewModel MenuPageViewModel
  mvx: Error: 11,84 Error seen during navigation request to MenuPageViewModel - error InvalidOperationException: Window must be the root element of the tree. The Window element can not be added as a child element of Visual.
  in System.Windows.Window.OnAncestorChanged ()
     in System.Windows.FrameworkElement.OnAncestorChangedInternal (TreeChangeInfo parentTreeState)
     in System.Windows.TreeWalkHelper.OnAncestorChanged (DependencyObject d, TreeChangeInfo info, Boolean visitedViaVisualTree)
     in System.Windows.DescendentsWalker`1.StartWalk (DependencyObject startNode, Boolean skipStartNode)
     in MS.Internal.PrePostDescendentsWalker`1.StartWalk (DependencyObject startNode, Boolean skipStartNode)
     in System.Windows.TreeWalkHelper.InvalidateOnTreeChange (FrameworkElement fe, FrameworkContentElement fce, DependencyObject parent, Boolean isAddOperation)
     in System.Windows.FrameworkElement.ChangeLogicalParent (DependencyObject newParent)
     in System.Windows.FrameworkElement.AddLogicalChild (Object child)
     in System.Windows.Controls.ContentControl.OnContentChanged (Object oldContent, Object newContent)
     in System.Windows.Window.OnContentChanged (Object oldContent, Object newContent)
     in System.Windows.Controls.ContentControl.OnContentChanged (DependencyObject d, DependencyPropertyChangedEventArgs e)
     in System.Windows.DependencyObject.OnPropertyChanged (DependencyPropertyChangedEventArgs e)
     in System.Windows.FrameworkElement.OnPropertyChanged (DependencyPropertyChangedEventArgs e)
     in System.Windows.DependencyObject.NotifyPropertyChange (DependencyPropertyChangedEventArgs args)
     in System.Windows.DependencyObject.UpdateEffectiveValue (EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry &amp; newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
     in System.Windows.DependencyObject.SetValueCommon (DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
     in System.Windows.DependencyObject.SetValue (DependencyProperty dp, Object value)
     in MvvmCross.Wpf.Views.Presenters.MvxSimpleWpfViewPresenter.Present (FrameworkElement frameworkElement) in D: \ git \ MvvmCross \ MvvmCross \ Windows \ Wpf \ Views \ Presenters \ MvxSimpleWpfViewPresenter.cs: line 41
     in MvvmCross.Wpf.Views.Presenters.MvxBaseWpfViewPresenter.Show (MvxViewModelRequest request) in D: \ git \ MvvmCross \ MvvmCross \ Windows \ Wpf \ Views \ Presenters \ MvxBaseWpfViewPresenter.cs: line 27
  </code></pre>