编辑:
以下是代码的 pastebin:
编辑 2
我在此处添加了 MS Connect 票证:
这是一个令人头疼的问题,我希望其他人已经经历过并且知道如何解决,因为我对整个事件感到有点沮丧。
问题
我一直在使用 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.cs 或 BooleanToVisibility.cs。我做了什么来尝试解决这个问题:
- Investigated other SO Posts , 无济于事
- 不幸删除了解决方案 SUO 文件
- 删除了我的 XAML 文件、类(模型和 ViewModel)并删除了公共(public)类并创建了一个新的基本页面。这会导致项目再次加载类。同样的问题。
- 删除了对用于自定义 DatePicker 控件的 Syncfusion Controls for WinRT XAML 的引用。还是一样的问题。
- 修复了 Visual Studio 2012 - 什么都没发生,问题仍然存在。
我完全不知所措。我创建了一个新项目,但问题不存在。我真的不想再次开始我的项目!
仅供引用 - LayoutPageAware.cs 包含在项目中:
最佳答案
我相信 LayoutAwarePage
是在 Common 文件夹中定义的,并且会在您第一次创建 Basic Page
- 右键单击您的项目
- 点击添加
- 点击“新项目”
- 点击“基本页面”
- 点击添加。
你可能会看到一个对话框说
“此添加依赖于您的项目中缺少的文件。如果没有这些文件,您必须手动解决对 Common 命名空间的依赖性。自动添加缺少的文件?”
点击是
然后再次尝试构建
关于C#/XAML 编译错误 - 各种错误(名称 "LayoutAwarePage"不存在”),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13461941/