Reputation: 4480
This is a very, very simple question, but I can't seem to find the answer. I have a WPF application that I've made a bunch of windows for. I've decided now that I want a different window to be the first one to open when the application is started. The default first window is MainWindow, how do I change it so another window opens first?
Upvotes: 22
Views: 22693
Reputation: 369
You can also do this from the code behind by overriding the 'OnStartup' method in App.xaml.cs as below.
Do take note to remove the StartupUri="Test.xaml" from the App.xaml
protected override void OnStartup(StartupEventArgs e)
{
Test window = new Test();
window.Show();
}
Upvotes: 5
Reputation: 11651
Open your App.xaml file and update the StartupUri:
<Application x:Class="WpfHacking.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml"> <!-- This is the line you want to update -->
</Application>
Upvotes: 41