zoukankan      html  css  js  c++  java
  • WPF的启动项

    最近需要给软件加上登陆界面,所以需要修改WPF的APP

    首先,在APP.xaml.cs中写界面的启动程序:

     public partial class App : Application
        {
            protected override void OnStartup(StartupEventArgs e)
            {
                Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;
                
                 if (******)
                 {
                     base.OnStartup(e);
                     Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
                     MainWindow window = new MainWindow();
                     window.Show();
                 }
                 else
                 {
                     if (System.Windows.MessageBox.Show("Can't open the software! ", "Warning", System.Windows.MessageBoxButton.OK) == System.Windows.MessageBoxResult.OK)
                     {
                         this.Shutdown();
                     }
                 }
            }
            //static App()
            //{
            //    DispatcherHelper.Initialize();
            //}
        }

    然后在App.xaml中修改StartupUri,一定不能为MainWindow.xaml,否则就算启动条件不正确,程序还在运行MainWindow。

    <Application    x:Class="***.App"> 这个一定要加,否则App.xaml.cs根本不运行。

    </Application>

  • 相关阅读:
    滑雪(dp好题)
    田忌赛马
    反质数(Antiprimes)
    LCA-倍增法(在线)
    二模 (2) day2
    Spring Integration
    [转载] Spring MVC
    收藏夹
    Linux profile File
    git merge 与 rebase 的区别
  • 原文地址:https://www.cnblogs.com/syqun/p/4158521.html
Copyright © 2011-2022 走看看