WPF应用程序是有主函数的,其启动先从主函数中开始,该主函数在App.g.cs文件中,该文件不显示在解决方案中,路径为obj/x86/Debug下。

    先从主函数中启动,再调用InitializeComponent()函数加载页面。App.g.cs文件可以删除,删除之后自己新建一个类重写启动函数,并在函数中可以设置初始启动的页面,其代码可如下所示:

       static void Main()

{

  App app=new App();

  uri ri=null;

  ri=new uri("xxx.xaml",urikind.Relative);   //xxx.xaml是要设置的初始启动页面

  app.Startupuri=ri;

  app.Run();

}

相关文章:

  • 2021-06-24
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
  • 2022-02-04
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
  • 2022-02-05
  • 2022-12-23
  • 2021-11-17
相关资源
相似解决方案