views:

433

answers:

4

I have this XAML:

<UserControl x:Class="M_Cubed.Controls.TagEditor"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:classes="clr-namespace:M_Cubed.Classes">
    <UserControl.Resources>
        <DataTemplate DataType="{x:Type classes:TagEditorPic}">
            <ComboBox DataContext="{StaticResource PicTypes}"
                ItemsSource="{Binding}"/>
        </DataTemplate>
    </UserControl.Resources>
</UserControl>

I have this C#:

namespace M_Cubed.Classes
{
     public class TagEditorPic : INotifyPropertyChanged
     {
          public TagEditorPic() { }
     }
}

And I get this error:

Type reference cannot find public type named 'TagEditorPic'.

Any suggestions?

+1  A: 

It's because you didn't implement INotifyPropertyChanged. If you implement that, then your control will compile.

It doesn't find the control because it can't compile the TagEditorPic class in the first place. Since that isn't a viable class, the XAML parser doesn't know what to do.

casperOne
Sorry I didnt post all my code. I do implement INotifyPropertyChanged. The code compiles and runs just fine. That error is only in the designer view.
Nick
A: 

Depending on your version of Visual Studio you could be getting stale assemblies.

Try running Build -> Clean Solution, then Rebuild Solution.

If that doesn't work try restarting Visual Studio.

bendewey
Neither of those worked.
Nick
A: 

I decided I'll just set the x:Key attribute on the datatemplate and just bind the template properties onwards to the StaticResource of the x:Key. It works fine with me.

Nick
A: 

is the TagEditorPic class in the same assembly? Else you need to specify it like this:

xmlns:classes="clr-namespace:M_Cubed.Classes;assembly=myassembly"
Sven Hecht
It sure is the same assembly
Nick