gpt4 book ai didi

c# 不包含 "InitializeComponent"的定义并且名称 "controlName"在当前上下文中不存在

转载 作者:太空狗 更新时间:2023-10-29 19:42:31 30 4
gpt4 key购买 nike

自 6 月以来,我一直在团队中开发 Windows Phone 应用程序。直到今天,所有同步都运行良好。我同步了项目,vs 开始给我错误

  • “WindowsPhoneApp.MainPage”不包含 InitializeComponent 的定义(以及所有其他页面,甚至 App)
  • 名称“controlName”在当前上下文中不存在(这发生在所有页面中)

我没有做任何更改,昨天它运行良好。 XAML 上的类名称与代码隐藏中的名称匹配。
我已经尝试退出所有 vs 实例,但问题仍然存在。

最佳答案

对我来说,问题如下:


项目结构

Project\Views\Page1.xaml
Project\Views\Page1.xaml.cs

上述页面构造函数Page1.xaml.cs中的错误:

public sealed partial class Page1 : Page
{
public Page1()
{
this.InitializeComponent();
}
}

Xaml 文件

<Page
x:Class="App1.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

应该是 x:Class="App1.Views.Page1"

所以只是在类名中打错了。

关于c# 不包含 "InitializeComponent"的定义并且名称 "controlName"在当前上下文中不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32806815/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com