title: Silverlight MVVM wire usercontrols to viewmodels
body: <p>I am at a loss over something that is probably incredibly simple.
  I did search but faield to find an exact answer that i needed.</p>
  
  <p>The problem is as followed.</p>
  
  <p>I am teaching myself silverlight MVVM.
  Currently I'm writing an application that uses 1 mainpage and 2 usercontrolls.</p>
  
  <p>As you can imagine, 3 viewmodels.</p>
  
  <p>Currently in my XAML:</p>
  
  <p>mainpage.xaml</p>
  
  <pre><code>xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:vm="clr-namespace:newFileupload.ViewModel"
  xmlns:vw="clr-namespace:newFileupload.View"
  
  &lt;UserControl.DataContext&gt;
      &lt;vm:MainPageViewModel /&gt;
  &lt;/UserControl.DataContext&gt;
  
  &lt;Grid x:Name="LayoutRoot" Background="White"&gt;
      &lt;vw:PicturesOverviewView /&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>PicturesOverviewView.xaml</p>
  
  <pre><code>xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  
  &lt;Grid x:Name="LayoutRoot" Background="White"&gt;
  
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>So in mainpage.xaml, I set the datacontext in xaml, i then call the usercontrol in the grid like so:</p>
  
  <pre><code>&lt;vw:PicturesOverviewView /&gt;
  </code></pre>
  
  <p>This gives me the following error:</p>
  
  <pre><code>Error   1   Cannot create an instance of "PicturesOverviewView".    C:\Programming\C#\newFileUpload\newFileupload\MainPage.xaml 16  9   newFileupload
  </code></pre>
  
  <p>I have absolutely no clue what is causing this, and secondly..</p>
  
  <p>How do I bind view models to the appropriate usercontrol?</p>
  
  <p>Do I need to declare the view namespace for every usercontrol and then set its datacontext like the mainpage? </p>
  
  <p>Thanks for taking the time to read and I hope to be able to continue soon :)</p>