简体   繁体   中英

How to change the main window in compact framework?

Is there some equivalent of wpf's Application.MainWindow in compact framework? The issue i have is that i run the SplashScreen, it does some work, and i need to close it and open the login page. I try to just close the form and open another one, but it closes the entire application, as the SplashScreen is the one I pass to the Application.Run() method

I don't want to hide the form, because it causes problems when I want to hide my entire application and call another application from my code(the splash screen seems to be still there even though i do call the hide method), so i need to close the splash screen and open the login screen

You have a few options.

  1. Don't pass your splash screen to Application.Run . Send in your main form, then have it create the instance of the splash and handle showing and hiding it. Really that screen (or any view for that matter) shouldn't be doing any "work" anyway - the work should be being done elsewhere and the UI should only react by displaying status, progress, validating user input etc.
  2. Use two sequential calls to Application.Run :

ie

Application.Run(new SplashScreen());
Application.Run(new MainForm());

Set: App.xaml (property) -> Build Action -> "Page"

Set in App.xaml.cs Main() :

[System.STAThreadAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public static void Main()
{
  SplashScreen ss = new SplashScreen();
  ss.showDialog();
  App app = new App();
  app.InitializeComponent();
  app.Run(); 
}

Set App.xaml:

<Application 
  //something
  StartupUri="MainWindow.xaml">
  //something
</Application>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM