WPF 从Main()方法启动

1.去掉App.xaml

StartupUri="MainWindow.xaml"

只会让App.g.cs 不生成这行代码,但是还是会生成的App.g.cs文件中生成Main方法

复制代码
this.StartupUri = new System.Uri("MainWindow.xaml", System.UriKind.Relative);

默认的App.xaml的生成操作是 应用程序定义,将其修改为页

在VS中的属性界面修改存在问题,编辑项目文件,添加下面代码

在vs中属性界面修改成页会在项目文件中增加,但是存在问题

图标变成

csharp 复制代码
<ItemGroup>
    <ApplicationDefinition Remove="App.xaml" />
</ItemGroup>

修改项目文件。图标正常

csharp 复制代码
  <ItemGroup>
    <ApplicationDefinition Remove="App.xaml" />
      <Page Include="App.xaml" />
  </ItemGroup>

修改成页后生成的文件就不生成main方法了

StartupUri="MainWindow.xaml"

去掉StartupUri="MainWindow.xaml"

相关推荐
bugcome_com9 小时前
WPF 命令 ICommand 从原理到实战
后端·wpf·icommand
武藤一雄1 天前
WPF处理耗时操作的7种方法
microsoft·c#·.net·wpf
Venom841 天前
我的 WPF Powermill 工具
wpf
一念春风2 天前
证件照制作工具(WPF C#)
c#·wpf
He BianGu3 天前
【笔记】在WPF中GiveFeedbackEventHandler的功能和应用场景详细介绍
笔记·wpf
就是有点傻3 天前
WPF自定义控件-水晶球
wpf
He BianGu3 天前
【笔记】在WPF中QueryContinueDragEvent的详细介绍
笔记·wpf
He BianGu3 天前
【笔记】在WPF中QueryCursor事件的功能和应用场景详细介绍
笔记·wpf
He BianGu3 天前
【笔记】在WPF中CommandManager的功能和应用场景详细介绍
笔记·wpf
关关长语3 天前
HandyControl中Button图标展示多色路径
c#·.net·wpf·handycontrol