C#/XAML 编译错误 - 各种错误(名称 "LayoutAwarePage"不存在”)

标签 c# compiler-errors visual-studio-2012 winrt-xaml

编辑:

以下是代码的 pastebin:

BasicPage1.xaml.cs

BasicPage1.xaml

LayoutAwarePage.cs

编辑 2

我在此处添加了 MS Connect 票证:

https://connect.microsoft.com/VisualStudio/feedback/details/771648/c-xaml-compile-error-various-errors-the-name-layoutawarepage-does-not-exist#tabs

这是一个令人头疼的问题,我希望其他人已经经历过并且知道如何解决,因为我对整个事件感到有点沮丧。

问题

我一直在使用 C#/XAML 开发 Windows 应用商店应用程序,以了解基本原理。经过几个小时的学习后,我决定开始自己的应用程序,这很好。问题是,在添加一些 View 等之后,我的 XAML 文件(所有文件)中开始出现以下错误:

Error 5 The name "LayoutAwarePage" does not exist in the namespace "using:Accountable.Common". G:\Coding Projects\Visual Studio 2012\SAVED\Accountable\Accountable\BasicPage1.xaml 1 1 Accountable

这很奇怪,因为 Accountable.Common 是在 XAML 文件中声明的:

<common:LayoutAwarePage
x:Name="pageRoot"
x:Class="Accountable.BasicPage1"
DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Accountable"
xmlns:common="using:Accountable.Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

所以我读了here关闭 XAML 文件并关闭 Visual Studio 2012 并重新打开,加上构建,可以解决此问题。它没有。它现在会在您首次创建新模板时创建的公用文件中导致以下错误:

Error 1 'Accountable.Common.BooleanNegationConverter' does not implement interface member 'Windows.UI.Xaml.Data.IValueConverter.ConvertBack(object, System.Type, object, string)' G:\Coding Projects\Visual Studio 2012\SAVED\Accountable\Accountable\Common\BooleanNegationConverter.cs 9 25 Accountable

Error 2 'Accountable.Common.BooleanNegationConverter' does not implement interface member 'Windows.UI.Xaml.Data.IValueConverter.Convert(object, System.Type, object, string)' G:\Coding Projects\Visual Studio 2012\SAVED\Accountable\Accountable\Common\BooleanNegationConverter.cs 9 25 Accountable

Error 3 'Accountable.Common.BooleanToVisibilityConverter' does not implement interface member 'Windows.UI.Xaml.Data.IValueConverter.ConvertBack(object, System.Type, object, string)' G:\Coding Projects\Visual Studio 2012\SAVED\Accountable\Accountable\Common\BooleanToVisibilityConverter.cs 20 25 Accountable

Error 4 'Accountable.Common.BooleanToVisibilityConverter' does not implement interface member 'Windows.UI.Xaml.Data.IValueConverter.Convert(object, System.Type, object, string)' G:\Coding Projects\Visual Studio 2012\SAVED\Accountable\Accountable\Common\BooleanToVisibilityConverter.cs 20 25 Accountable

我没有更改 BooleanNegationConverter.csBooleanToVisibility.cs。我做了什么来尝试解决这个问题:

  1. Investigated other SO Posts , 无济于事
  2. 不幸删除了解决方案 SUO 文件
  3. 删除了我的 XAML 文件、类(模型和 ViewModel)并删除了公共(public)类并创建了一个新的基本页面。这会导致项目再次加载类。同样的问题。
  4. 删除了对用于自定义 DatePicker 控件的 Syncfusion Controls for WinRT XAML 的引用。还是一样的问题。
  5. 修复了 Visual Studio 2012 - 什么都没发生,问题仍然存在。

我完全不知所措。我创建了一个新项目,但问题不存在。我真的不想再次开始我的项目!

仅供引用 - LayoutPageAware.cs 包含在项目中:

enter image description here

最佳答案

我相信 LayoutAwarePage 是在 Common 文件夹中定义的,并且会在您第一次创建 Basic Page

时自动生成
  • 右键单击您的项目
  • 点击添加
  • 点击“新项目”
  • 点击“基本页面”
  • 点击添加。

你可能会看到一个对话框说

“此添加依赖于您的项目中缺少的文件。如果没有这些文件,您必须手动解决对 Common 命名空间的依赖性。自动添加缺少的文件?”

点击是

然后再次尝试构建

关于C#/XAML 编译错误 - 各种错误(名称 "LayoutAwarePage"不存在”),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13461941/

相关文章:

c# - Xamarin ndk 从 c 函数获取字符串作为返回值

C# TreeView.GetNodeAt() 单击图像的问题

c - 函数指针 IAR (typedef void)

batch-file - 使用SendKeys方法的.vbs文件中的VBScript错误 “End of Statement”

c# - LinQ ofType in 值

c++ - 有没有人考虑过更多 "strict"风格的 C++,其中默认/需要初始化变量?

c# - Windows 应用商店应用、加密、提供的用户缓冲区对于请求的操作无效

c++ - 将 std::chrono::system_clock::time_point::min() 转换为字符串时出现无效空指针错误

visual-studio-2012 - 在 Visual Studio 2012 中连接到 TFS 源时出现异常

c# - 如何加载两个模型以在 MVC5 中生成单个输出