加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 手动创建WPF项目

发布时间:2020-12-15 04:16:50 所属栏目:百科 来源:网络整理
导读:我正在尝试创建一个不使用VS2010中的自动生成文件的wpf项目,我认为它可以帮助我更好地理解,所以我希望这听起来不是超级原始的问题. 无论如何,在使xaml文件及其代码落后于例如myWindow.xaml和myWindow.xaml.cs我还创建了App.xaml及其代码. 在我运行代码并收到
我正在尝试创建一个不使用VS2010中的自动生成文件的wpf项目,我认为它可以帮助我更好地理解,所以我希望这听起来不是超级原始的问题.

无论如何,在使xaml文件及其代码落后于例如myWindow.xaml和myWindow.xaml.cs我还创建了App.xaml及其代码.

在我运行代码并收到此消息之前,事情似乎还可以:

‘test1.exe’ does not contain a static ‘Main’ method suitable for an
entry point

这是我到目前为止:

<Application x:Class="test1.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="myWindow.xaml">
    <Application.Resources>

    </Application.Resources>
</Application>


namespace test1
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        public App()
        {
            InitializeComponent();
        }
    }
}

然后有

<Window x:Class="test1.myWindow"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             >
    <Grid>

    </Grid>
</Window>



namespace test1
{
    /// <summary>
    /// Interaction logic for myWindow.xaml
    /// </summary>
    public partial class myWindow : Window
    {
        public myWindow()
        {
            InitializeComponent();
        }
    }
}

可能是由于这里生成了错误的BAML文件?因为Main()通常在构建过程中被放置.

解决方法

需要将App.xaml的Build Action设置为“ApplicationDefinition”,以便为您生成Main.它可能设置为“Page”,XAML文件的默认值.选择App.xaml文件时查看属性.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读