MVVM Light - Changing the startup URI <p>Having created a new WPF 4.5 MVVM Light Application, I wanted to change the startup URI so that I could do some checks before the app starts. I made the following change to App.xaml:</p> <pre><code>&lt;Application x:Class="MvvmLight1.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vm="clr-namespace:MvvmLight1.ViewModel" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" StartupUri="MainWindow.xaml" mc:Ignorable="d"&gt; </code></pre> <p>To:</p> <pre><code>&lt;Application x:Class="MvvmLight1.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vm="clr-namespace:MvvmLight1.ViewModel" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"&gt; </code></pre> <p>And added an <code>OnStartup</code> method to the <code>App.xaml.cs</code>:</p> <pre><code>public partial class App : Application { static App() { DispatcherHelper.Initialize(); } protected override void OnStartup(StartupEventArgs e) { //base.OnStartup(e); MainWindow win = new MainWindow(); win.Show(); } } </code></pre> <p>Doing this seems to change the context that the window runs in. I did try setting the data context to the MainViewModel, but this didn't seem to help.</p>