【发布时间】:2022-11-17 17:02:58
【问题描述】:
我已经坚持了几个小时,“InitializeComponent”在当前上下文中不存在。
public partial class CreateAccount : Window
{
public CreateAccount()
{
InitializeComponent();
}
这是我的 XAML 代码
<Window x:Class="HotelAccomadation.Interface.CreateAccount"
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"
xmlns:local="clr-namespace:HotelAccomadation.Interface"
mc:Ignorable="d"
Title="CreateAccount" Height="450" Width="800"
Background="AliceBlue"
>
我已确定名称相同,我还应该做什么?
【问题讨论】:
-
您是否尝试过清理和重建解决方案?
-
@Ibrennan208 是的 我有 我仍然有同样的错误
-
它与没有任何引用的第一页和 xaml.cs 'public Login()' 有什么关系吗?
-
obj`目录中的某处应该有一个CreateAccount.g.cs文件 - 你能找到它吗? (提示:使用VoidTools 一切找到它)。您在解决方案和/或该项目的依赖项中是否有任何其他项目存在构建错误? -
@Dai 不,我没有那个文件,我应该有吗?我有一个 xaml 页面,它有那个文件并且可以工作,有没有办法生成它?