title: WPF DataBinding with MVVM and User Controls
body: <p>Let's say I have a Customer Window showing information about a customer, like Name, address and phone number. On the bottom there is a DataGrid of their orders.  Of course the Customer has an Orders property, so if you're using MVVM, you would just set:</p>
  
  <pre><code>ItemsSource = "{Binding Customer.Orders}"
  </code></pre>
  
  <p>However, now let's say that the data grid is now part of a user control, which also includes controls for editing/adding/removing Orders. I want to use this same set of controls in multiple places, and I would like all the logic for editing/adding/removing Order objects to be encapsulated in the user control.  And because I want to use commands, rather than event handlers, I would like the user control to have its own view model.  </p>
  
  <p>So now the question is: how do I pass the orders from the Customer view model to the Orders user control's view model?  Because the Orders user control will be bound to a view model, I can't say:</p>
  
  <pre><code>&lt;local:OrdersUserControl DataContext="{Binding Customer.Orders}" /&gt;
  </code></pre>
  
  <p>because the user control has it's own view model.  It would expect to see Customer.Orders there, and of course it's not.</p>
  
  <p>I guess this is kind of a chicken or the egg situation.</p>
  
  <p>Your help is always appreciated.</p>
  
  <p>Aaron</p>