title: WPF: The ViewModel-type does not contain any accessible constructors
body: <p>I am instantiating my repository in my <code>MainViewModel</code> and passing this instance to use in my child <code>ViewModel</code> (i.e. <code>CategoryViewModel</code>).  I am getting a </p>
  
  <blockquote>
    <p>Severity  Code    Description Project File    Line
    Error       The type "CategoryViewModel" does not include any accessible constructors.  </p>
  </blockquote>
  
  <p>The error is coming from my main window where I have declared the Category user control and setting the <code>DataContext</code> to <code>CategoryViewModel</code>:</p>
  
  <pre><code>&lt;view:CategoryView Grid.Row="2" Grid.Column="0" Margin="5"&gt;
      &lt;view:CategoryView.DataContext&gt;
          &lt;viewModel:CategoryViewModel /&gt;
      &lt;/view:CategoryView.DataContext&gt;
  &lt;/view:CategoryView&gt;
  </code></pre>
  
  <p>I am not getting this error when I don't have any parameters in the <code>CategoryViewModel</code> constructor so I know it has something to do with that but not exactly sure what is causing the problem. I would appreciate any advice. Below is my <code>MainViewModel</code> and <code>CategoryViewModel</code>.</p>
  
  <pre><code>public class MainViewModel : BindableBase
  {
      private readonly IRepository _repo = new Repository();
      private CategoryViewModel _categoryViewModel;
  
      public MainViewModel()
      {
          _categoryViewModel = new CategoryViewModel(_repo);
      }
  }
  
  public class CategoryViewModel : BindableBase
  {       
      private IRepository _repo;
      public List&lt;Category&gt; CategoryCollection { get; set; }
  
      public CategoryViewModel(IRepository repo)
      {
          _repo = repo;            
         CategoryCollection = LoadCategory();
  
      }
  
      private List&lt;Category&gt; LoadCategory()
      {
          return _repo.GetAllCategories();
      }
  }
  </code></pre>