简体   繁体   English

如何在紧凑框架中更改主窗口?

[英]How to change the main window in compact framework?

Is there some equivalent of wpf's Application.MainWindow in compact framework? 在紧凑的框架中,有什么WPF的Application.MainWindow等效项? 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. 我的问题是我运行了SplashScreen,它做了一些工作,需要关闭它并打开登录页面。 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 我试图关闭窗体并打开另一个窗体,但是它关闭了整个应用程序,因为SplashScreen是我传递给Application.Run()方法的窗体。

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 我不想隐藏表单,因为当我想隐藏我的整个应用程序并从我的代码中调用另一个应用程序时,它会引起问题(即使我确实调用了hide方法,启动画面似乎仍然存在),所以我需要关闭启动画面并打开登录画面

You have a few options. 您有几种选择。

  1. Don't pass your splash screen to Application.Run . 不要将启动画面传递给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. 确实,该屏幕(或与此相关的任何视图)无论如何都不应做任何“工作”-该工作应在其他地方完成,并且UI应该仅通过显示状态,进度,验证用户输入等来做出反应。
  2. Use two sequential calls to Application.Run : 使用两个顺序调用Application.Run

ie

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

Set: App.xaml (property) -> Build Action -> "Page" 设置: App.xaml(属性)->构建操作->“页面”

Set in App.xaml.cs Main() : 在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: 设置App.xaml:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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