Amarnath
Amarnath

Reputation: 8855

MainWindow.xaml File Not found in wpf

I created a MainWindow.xaml file in visual studio. Then I clicked on run its working good. I created another file called SecondMainWindow.xaml, now I want to run the SecondMainWindow.xaml as the start file. But when I click run the MainWindow.xaml file is opening. So I excluded that file from the project. Now if I click run then it throw-ed an error saying

MainWindow.xaml does not exist.

Yes that is true because I have excluded it from my project.

But my question how to make SecondMainWindow.xaml as the file that should be opened first when I click on run.

Upvotes: 2

Views: 5931

Answers (3)

Nikhil Agrawal
Nikhil Agrawal

Reputation: 48558

In App.xaml under StartupUri attribute of Application tag change MainWindow.xaml to SecondMainWindow.xaml.

<Application StartupUri = "SecondMainWindow.xaml" >

</Application> 

BTW there was no need of removing MainWindow.xaml from project. You can have n number of xaml files. What you define in StartupUri property is the file which is run first.

Upvotes: 5

Menno Luimstra
Menno Luimstra

Reputation: 31

Go to the App.xaml file and change StartupUri="MainWindow.xaml" to StartupUri="SecondMainWindow.xaml"

Upvotes: 2

granaker
granaker

Reputation: 1328

Set StartupUri to SecondMainWindow.xaml in your App.xaml

Upvotes: 2

Related Questions