March 5, 2014

How to: Set the Startup Form in a WPF Application

Question: In my WPF project, I have two .xaml WPF forms (MainWindow.xaml and Window1.xaml), how do I set Window1.xaml as a startup form for my WPFproject.?

Solution: 
  • Double click on the App.xaml file, in the Solution Explorer window.
  • App.xmal file would open and would have the following xml
<Application x:Class="WPFTutorialDemo.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
         
    </Application.Resources>
</Application>

You need to change the StartupUri attribute (highlighted yellow) with the name of the form you want to set as startup, in this case Window1.xaml, Save and close the file.

Thanks,
Hussain Patel

No comments:

Post a Comment