开发者

Custom Classes in XAML give me unresolved tag errors

I've created the following XAML, approximately (shortened for brevity):

<Window ...
    xmlns:Models="clr-namespace:Project.Presentation.Models;assembly=Project"
    ...>
    &开发者_StackOverflow社区lt;Window.Resources>
        <Models:ProfileCollection x:Key="Profiles" />
    </Window.Resources>
</Window>

ProfileCollection is defined as, simply:

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

This follows the requirements set forth in XAML and Custom Classes on MSDN.

However, when I try to compile I get this error:

error MC3074: The tag 'ProfileCollection' does not exist in XML namespace 'clr-Project.Presentation.Models;assembly=Project'. Line 18 Position 7.

I've also tried:

<Window ...
    xmlns:SystemCollections="clr-namespace:System.Collections;assembly=mscorlib"
    ...>
    <Window.Resources>
        <SystemCollections:ArrayList x:Key="arrayList" />
    </Window.Resources>
</Window>

That works fine.

public class SomeList : ArrayList { public SomeList() { } }

I get the same error trying to use this object. It's the same error as before.

<Models:SomeList x:Key="arrayList" />  <!-- MC3074 -->


Is 'ProfileCollection' class placed in the namespace 'Project.Presentation.Models? Also if XAML and class are both in 'Project' assembly, try to remove "assembly=Project" from xmlns declaration

Good luck ;)


I got the same error. The reason were different .NET Frameworks (assembly had 4.6.1 and my base project had 4.5.1).

Maybe this information helps others (the error code is not very precise in my mind...).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜