C#/ XAML编译错误 - 各种错误(名称“LayoutAwarePage”不存在) [英] C#/XAML Compile Error - Various Errors (The name "LayoutAwarePage" does not exist")

查看:612
本文介绍了C#/ XAML编译错误 - 各种错误(名称“LayoutAwarePage”不存在)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑



以下是代码的粘贴位置:

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应用商店应用来学习绳索。经过几个小时的学习,我决定开始我自己的应用程序,这是罚款。问题是,在添加了一些视图等之后,我开始在我的XAML文件(所有这些)中得到以下错误:


错误5名称LayoutAwarePage不存在于命名空间
using:Accountable.Common中。 G:\Coding Projects\Visual Studio
2012\SAVED\Accountable\Accountable\BasicPage1.xaml 1 1责任


这很奇怪,因为 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>

所以我读了关闭XAML文件并关闭 Visual Studio 2012 并重新打开的/ details / 762100 / xaml-designer-doesnt-work#tabs =nofollow noreferrer加上Building,解决这个问题。它没有。现在在您首次创建新模板时创建的公用文件中会出现以下错误:


错误1'Accountable.Common.BooleanNegationConverter'不是
实现接口成员
'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责任



错误2'Accountable.Common.BooleanNegationConverter'不是
实现接口成员
'Windows.UI.Xaml.Data.IValueConverter.Convert(object,System.Type,
object,string)'G:\Coding Projects\Visual Studio
2012 \SAVED\Accountable\Accountable\Common\BooleanNegationConverter.cs 9



错误3'Accountable.Common.BooleanToVisibilityConverter'不是
实现接口成员
'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责任



错误4'Accountable.Common.BooleanToVisibilityConverter'不是
实现接口成员
'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责任


I haven未更改 BooleanNegationConverter.cs BooleanToVisibility.cs 。我做了什么尝试和解决问题:


  1. 删除了解决方案没有运气的SUO文件
  2. li>
  3. 删除了我的XAML文件,类(模型和视图模型)和删除的常见类,并创建了一个新的基本页面。这将导致项目再次加载类。同样的问题。

  4. 删除了用于自定义DatePicker控件的 Syncfusion控件for WinRT XAML 的引用。仍然是同样的问题。

  5. 修复了Visual Studio 2012 - 没有发生任何问题。

我完全失去了。我已经创建了一个新的项目,问题不存在。我真的不想再次开始我的项目。



FYI - LayoutPageAware.cs包含在项目中:



解决方案

我相信 LayoutAwarePage 是在Common文件夹中定义的,并且是在您第一次创建基本页面




  • 右键点击您的项目

  • 点击添加

  • 点击新项目

  • 点击基本页面

  • 点击添加。



您可能会收到一个对话框,说



这个添加取决于您的项目缺少的文件。



点击yes



然后尝试重新建立


EDIT:

Here are the pastebins for the code:

BasicPage1.xaml.cs

BasicPage1.xaml

LayoutAwarePage.cs

EDIT 2

I have added a MS Connect ticket here:

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

Right a head scratcher which I'm hoping others have experienced and know how to resolved as I'm a little disheartened by the whole affair.

The Problem

I have been working on a Windows Store App using C#/XAML to learn the ropes. After hours spent learning I decided to start my own App, which is fine. The issue is, after adding a few Views etc, I started getting the following error within my XAML files (All of them):

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

Which is strange because the Accountable.Common is declared within the XAML file:

<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">

So i read here that closing the XAML files down and closing Visual Studio 2012 and re-opening, plus Building, resolves this issue. It didnt. It now causes the following errors within the Common files created when you first create new templates:

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

I haven't changed BooleanNegationConverter.cs or BooleanToVisibility.cs. What have i done to try and resolved the issue:

  1. Investigated other SO Posts, to no avail
  2. Deleted the Solution SUO File with no luck
  3. Removed my XAML Files, Classes (Models and ViewModels) and deleted Common Classes and created a new Basic Page. This causes the Project to load the classes again. The same problem.
  4. Removed the reference to Syncfusion Controls for WinRT XAML which i used for custom DatePicker controls. Still the same issue.
  5. Repaired Visual Studio 2012 - Nothing happened still the same problems.

I'm completely at a loss. I have created a new Project and the problem doesn't exist. I dont really want to start my Project again!

FYI - LayoutPageAware.cs is included in the Project:

解决方案

I believe that the LayoutAwarePage is defined in the Common folder, and is automatically generated the first time you create a Basic Page

  • Right Click on your prject
  • Click Add
  • Click "New Item"
  • click "Basic Page"
  • click add.

You might get a dialog saying

"This addition depends on files that are missing from your project. Without these files you must resolve dependencies on the Common namespace manually. Add the missing files automatically?"

click yes

and then try building again

这篇关于C#/ XAML编译错误 - 各种错误(名称“LayoutAwarePage”不存在)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆