I have a BIG and OLD xaml user control and I am trying to add ViewModel class for it (to do the things right). the code for attach viewmodel in xaml is:
xmlns:vm="clr-namespace:Company.Proj.ViewModel;assembly=Company.Proj"
xmlns:v="clr-namespace:Company.Proj.View;assembly=Company.Proj"
mc:Ignorable="d">
<UserControl.Resources>
<DataTemplate
DataType="{x:Type vm:SampleVM}">
<v:MainWindow/>
</DataTemplate>
</UserControl.Resources>
<UserControl.DataContext>
<vm:SampleVM/>
</UserControl.DataContext>
and a class for future ViewModel:
namespace Company.Proj.ViewModel //the namespace is correct
{
public class SampleVM // the class is public
{
public SampleVM() // void constructor? perhaps not needed here
{
}
}
}
And I am getting SampleVM does not exist in the namespace clr-namespace:Company.Proj.ViewModel;assembly=Company.Proj"
I have googled a lot and found out many answers. like in The name ViewModel does not exist in the namespace "clr-namespace:Project.ViewModels"
...I have tried to rebuildProjec/reopenStudio/change debug-release-debug/carefully)) copypaste assembly and namespece names...
But nothing solved (( Is there any other variant to connect ViewModel to View.xaml(perhaps the better one that I have used) OR what coul be done to solve this issue ?
My VS version: VS Community 2013 12.0.3.1101.00 Update 4 Target Framework 4.5.1
EDIT: My question is different from above link because In my question there is no mistake in clr-path (see top answer of Will)