title: The name "IndustryViewModel" does not exist in the namespace "clr-namespace:KPI.CTC.ViewModel"
body: <p>I was trying to set the DataContext of view through XAML but faced the error that the name does not exist in the provided namespace.</p>
  
  <p><strong>XAML FILE</strong></p>
  
  <pre><code>&lt;UserControl x:Class="KPI.CTC.UI.Industry"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:vm="clr-namespace:KPI.CTC.ViewModel"
               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
               xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
               mc:Ignorable="d" 
               d:DesignHeight="300" d:DesignWidth="300"&gt;
  
      &lt;UserControl.DataContext&gt;
          &lt;vm:IndustryViewModel/&gt;
      &lt;/UserControl.DataContext&gt;
      &lt;Grid&gt;
          &lt;Button Content="{Binding Path=Name}"/&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>But when I tried to the same in xaml.cs, it worked perfectly.</p>
  
  <p><strong>XAML.CS FILE</strong></p>
  
  <pre><code>using System.Windows.Controls;
  using KPI.CTC.ViewModel;
  
  namespace KPI.CTC.UI {
      public partial class Industry : UserControl {
          public Industry() {
              InitializeComponent();
              this.DataContext = new IndustryViewModel();
          }
      }
  }
  </code></pre>
  
  <p><strong>VIEWMODEL Class</strong></p>
  
  <pre><code>using GalaSoft.MvvmLight;
  
  namespace KPI.CTC.ViewModel {
      public class IndustryViewModel : ViewModelBase {
  
          public string Name { get; set; }
          public IndustryViewModel() {
              Name = "MyString";
          }
      }
  }
  </code></pre>
  
  <p>Can anyone please explain why am I not able to set the DataContext through xaml?</p>