Application StartupUri in WPF

StartupUri property gets or sets a UI that is automatically shown when an application starts.

You can change StartupUri of an application to a window you want to display when your application starts.

<Application x:Class="WPFSample.App"

             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

             StartupUri="Window1.xaml"

             >

 </Application>


Listing 1 sets the StartupUri of application to SecondWindow.xaml in code behind.

Application curApp = Application.Current;
curApp.StartupUri = new Uri("SecondWindow.xaml", UriKind.RelativeOrAbsolute );

 

Listing 1