WPF Error: The type reference cannot find a public type named ‘xxx’

This got me confused. I have MyViewModel class inside MyNamespace namespace.

namespace MyNamespace
{
	public class MyViewModel
	{
		//Stuff...
	}
}

Inside my XAML, I add reference to my namespace and the assembly name.

xmlns:viewModel="clr-namespace:MyNamespace;assembly=MyProject.GUI"

I try to use my type, eg.

<HierarchicalDataTemplate DataType = "{x:Type viewModel:MyViewModel}">
	< !--Stuff... -- >
</HierarchicalDataTemplate>

When trying to build the solution I get exception:
The type reference cannot find a public type named ‘MyViewModel’

So, what gives? Because my XAML file is in the same assembly as my ViewModel, I do not need to specify the assembly. After removing it from XAML code, everything works fine.

xmlns:viewModel="clr-namespace:MyNamespace"
Advertisements
Create your website at WordPress.com
Get started
%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close