title: WPF User Control hell with MVVM and Dependency Properties
body: <p>This is what I'm trying to do:</p>
  
  <ul>
  <li>I'm writing a <code>UserControl</code> that I want to be consumed by other developers.</li>
  <li><p>I want end users to be able to use my control using Dependency Properties.</p>
  
  <pre><code>&lt;lib:ControlView ControlsText={Binding Path=UsersOwnViewModelText} /&gt;
  </code></pre></li>
  <li><p>I'm using the MVVM pattern.</p></li>
  <li><p>I'm binding my ViewModels to their View's using <code>&lt;DataTemplates&gt;</code></p>
  
  <pre><code>&lt;DataTemplate DataType="{x:Type local:ControlViewModel}"&gt;  
      &lt;local:ControlView /&gt;  
  &lt;/DataTemplate&gt;
  </code></pre></li>
  </ul>
  
  <p>So I have two questions:</p>
  
  <ol>
  <li><p>Am I right in thinking that if a UserControl is being consumed in XAML then the UserControl must set the ViewModel as its <code>DataContext</code> when the control's <code>Loaded</code> event fires instead of using the <code>&lt;DataTemplate&gt;</code> method?</p></li>
  <li><p>How do I allow users to data bind to my control's dependency properties while still being data bound to my ViewModel?</p></li>
  </ol>