App.xaml file does not get parsed if my app does not set a StartupUri?

后端 未结 4 2076
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 01:07

Background: I\'m creating a WPF app using MVVM, and using a DI container to build my ViewModels

My App.xaml looks like this:



        
4条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-30 01:40

    Rather than overriding OnStartup, try using an event instead:

    
            
                
            
        
    

    Code behind:

    public partial class App : Application
    {
        public App()
        { }
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            // TODO: Parse commandline arguments and other startup work 
            new MainWindow().Show();
        }
    }
    

提交回复
热议问题