title: Binding app.xaml to view WPF in c#
body: <p>I use MVVM framework and got this tutorial on net: <a href="https://code.msdn.microsoft.com/windowsdesktop/How-to-use-MVVM-Pattern-0e2f4571" rel="nofollow">https://code.msdn.microsoft.com/windowsdesktop/How-to-use-MVVM-Pattern-0e2f4571</a> and <a href="http://www.c-sharpcorner.com/UploadFile/raj1979/simple-mvvm-pattern-in-wpf/" rel="nofollow">http://www.c-sharpcorner.com/UploadFile/raj1979/simple-mvvm-pattern-in-wpf/</a></p>
  
  <p>Now, my problem is:</p>
  
  <p>I can't display the mainpage.xaml even there is no semantic error. Here's my code on app.xaml.cs:</p>
  
  <pre><code>protected override void OnStartup(StartupEventArgs e)
  {
      base.OnStartup(e);
      BasicWPF.View.MainPage window = new MainPage();
      UserViewModel VM = new UserViewModel();
      window.DataContext = VM;
      window.Show();
  }
  </code></pre>
  
  <p>Can anyone help me? Thanks for any help! :)</p>
  
  <p>Thanks to everyone who helped.</p>
  
  <p>[SOLVED]</p>
  
  <p>Change the startupuri in app.xaml to where the page you want to load. In my case </p>
  
  <p>1: I change it:</p>
  
  <pre><code>StartupUri="View/MainPage.xaml"
  </code></pre>
  
  <p>2: In app.xaml.cs, I typed in this code:</p>
  
  <pre><code>protected override void OnStartup(StartupEventArgs e)
  {
      base.OnStartup(e);
      BasicWPF.View.MainPage window = new MainPage();
      UserViewModel VM = new UserViewModel();
      window.DataContext = VM;
  }
  </code></pre>
  
  <p>from my previous code, delete this code: window.show(); because it startup the page twice coming from app.xaml and app.xaml.cs. To prevent that, delete: window.show();</p>
  
  <p>Thank you again! :)</p>