c#WPF无法设置启动

 虎爷2602900775 发布于 2023-02-10 11:21

我在WPF有项目.

问题是,当我将App.xaml文件移动到子文件夹时,它不想编译,因为它找不到main方法.

如何强制Project使用App.xaml文件中设置的窗口启动应用程序作为启动窗口?

我使用Visual Studio 2010 express.

编辑:

我的App.xaml


    

    

项目中的子文件夹:

查看,模型,ViewModel等....

1 个回答
  • 我使用OnStartup:App.xaml使用自定义启动窗口解决了这个问题

    <Application x:Class="Pin.Visualisation.App"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 Startup="OnStartup">
        <Application.Resources>
    
        </Application.Resources>
    </Application>
    

    App.xaml.cs

    namespace Pin.Visualisation
    {
        public partial class App : Application
        {
            private void OnStartup(object sender, StartupEventArgs e)
            {
                var view = new MainWindow();
                view.Show();
            }
        }
    }
    

    我的MainWindow存储在View/MainWindow中.对你有用吗?

    2023-02-10 11:25 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有