XAML中的自定义类给出了未解决的标记错误

Rob*_*Rob 2 c# wpf xaml

我已经创建了以下XAML(简称为缩短版):

<Window ...
    xmlns:Models="clr-namespace:Project.Presentation.Models;assembly=Project"
    ...>
    <Window.Resources>
        <Models:ProfileCollection x:Key="Profiles" />
    </Window.Resources>
</Window>
Run Code Online (Sandbox Code Playgroud)

ProfileCollection简单地定义为:

public class ProfileCollection : ObservableCollection<Profile>
{
    public ProfileCollection()
    {
        foreach (Profile p in Configuration.Instance.Profiles)
            this.Add(p);
    }
    // code that handles static added/removed events
}
Run Code Online (Sandbox Code Playgroud)

这符合MSDN上XAML和自定义类中规定的要求.

但是,当我尝试编译时,我收到此错误:

错误MC3074:XML命名空间'clr-Project.Presentation.Models; assembly = Project'中不存在标记'ProfileCollection'.第18行位置7.

我也尝试过:

<Window ...
    xmlns:SystemCollections="clr-namespace:System.Collections;assembly=mscorlib"
    ...>
    <Window.Resources>
        <SystemCollections:ArrayList x:Key="arrayList" />
    </Window.Resources>
</Window>
Run Code Online (Sandbox Code Playgroud)

这很好.

public class SomeList : ArrayList { public SomeList() { } }
Run Code Online (Sandbox Code Playgroud)

尝试使用此对象时出现同样的错误.这是和以前一样的错误.

<Models:SomeList x:Key="arrayList" />  <!-- MC3074 -->
Run Code Online (Sandbox Code Playgroud)

sll*_*sll 6

'ProfileCollection'类是否放在命名空间中'Project.Presentation.Models?此外,如果XAML和类都在'Project'汇编中,请尝试assembly=Project从xmlns声明中删除" "

祝好运 ;)