i'm relatively new to WPF and i was tasked to convert an old winforms project into a wpf project.
I am using the function App_Startup as the start for the App and i already created a mainwindow for my GUI. Normally you would just do this in the startup:
void App_Startup(object sender, StartupEventArgs e)
{
MainWindow main = new MainWindow();
main.Show();
}
but this does not work for me because it shows a completely new mainwindow and ignores the one i already made. I understand the issue is that App_Startup happens before the mainwindow and its components even get initialized but there has to be a way i can jump into the mainwindow let it initialize itself and its components and make that the window i start in App_Startup, but I just don't know how to do that.
I'm sorry if this is a really easy to solve problem, but i just don't know how to solve it.
Also i'm sorry if the English sucks it is not my first language.
Thank you very much for your answers and help in advance.
Greetings from Germany
CodePudding user response:
First, open your App.xaml, then change StartupUri to what you need.
CodePudding user response:
for changing the startup form in WPF projects, open the App.XML file and change the StartupUri String with your new Window.
That should be the trick.
Greetings from Austria ✌