为了说明问题,我创建了一个简单的示例项目,在 XAML 定义中遇到了编译错误。
以下是我的类定义:
我遇到了以下错误信息:
以下是我的类定义:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MVVMTest.Foo
{
public class FooTestClass
{
public String Name { get; set; }
public String Key { get; set; }
}
}
需要注意的是FooTestClass位于MVVMTest文件夹的Foo子文件夹中。
以下是我的XAML代码:
<Window x:Class="MVVMTest.MainWindow"
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:MVVMTest"
xmlns:mView="clr-namespace:MVVMTest.Foo;assembly=MVVMTest"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<mView:FooTestClass x:Key="ddd" />
</Window.Resources>
<Grid>
</Grid>
</Window>
我遇到了以下错误信息:
这是由于VS出现了问题吗?标记“FooTestClass”在XML命名空间“clr-namespace:MVVMTest.Foo;assembly=MVVMTest”中不存在。行12,位置10。
MVVMTest C:\Dev Projects\MVVMTest\MVVMTest\MainWindow.xaml