title: C# WPF Navigation Between Pages (Views)
body: <p>I'm attempting to create a class &amp; method which could be used on any window and page to change the current page displayed on the MainWindow window.</p>
  
  <p>So far I got:</p>
  
  <pre><code>class MainWindowNavigation : MainWindow
  {
      public MainWindow mainWindow;
  
     public void ChangePage(Page page)
      {
          mainWindow.Content = page;
      }
  }
  </code></pre>
  
  <p>The main window itself:</p>
  
  <pre><code>public MainWindow()
      {
          InitializeComponent();
          MainWindowNavigation mainWindow = new MainWindowNavigation();
          mainWindow.ChangePage(new Pages.MainWindowPage());
      }
  </code></pre>
  
  <p>Unfortunately this ends up with System.StackOverflowException.</p>
  
  <p>The main reason for creating this is that I want to be able to change the mainWindow.Content from a page which is currently displayed in mainWindow.Content.</p>
  
  <p>I have already reviewed MVVM but I don't think it is worth using it for a small application like this as all I want it to do is Display a Welcome Page on open, then on the side there will be few buttons. Once pressed the mainWindow.Content correctly changes to a page where a user can enter login detail and then on the button press on the login page I want to change the mainWindow.Content to a different page on successful validation of the login details entered.</p>