title: WPF Usercontrol interaction with parent view / viewmodel
body: <p>Hi I have a mainView window which has its dataContext set to it's own viewModel.</p>
  
  <p>On that viewModel is a DateTime property which in turn is bound to a datepicker on my main view using 2 way binding.</p>
  
  <pre><code>&lt;toolkit:DatePicker DateSelected="{Binding mainDateTimeProperty, Mode=TwoWay}" /&gt;
  </code></pre>
  
  <p>This is all fine so far. On the change of my datetime property I create a list which is then bound to a datagrid elsewhere on the mainview. This all works fine.</p>
  
  <p>My question is to do with a usercontrol I want to add to the main view. I want this usercontrol to be self contained so have created it with it's own viewmodel but it does also need access to <code>mainDateTimeProperty</code></p>
  
  <p>I thought that best way to go would be to create a dependencyProperty on the usercontrol and when I create my control in the main view I bind the dp to the datetime as follows.</p>
  
  <pre><code>&lt;uc:MyNewUserControl DateProperty="{Binding mainDateTimeProperty}" /&gt;
  </code></pre>
  
  <p>Trouble is how do I have the usercontrol maintain datacontext with it's viewmodel and yet still have the dependency property bound to a property on the main view model?</p>
  
  <p>Hope this is clear. Can post some more code if necessary. Looking for a best practice approach if possible. </p>
  
  <p>Thanks very much for any advice.</p>