title: Setting DataContext for ContextMenu in ItemsControl.DataTemplate
body: <p>I have custom control that is being used in data template for an ItemsControl.  I want to put a ContextMenu on each item and have it call the UserControl's View Model to process the command.  Using the XAML below, I can get click events on the custom control to call the SelectedItemCommand in the user control view model.  But, using similar syntax for the context menu fails.  By default I get the view mode per each custom control.  Any of the RelativeSource syntax value I use don't resolve to the user control's view model (RelativeSource Self).</p>
  
  <p>What's the magic code?</p>
  
  <pre><code>        &lt;ItemsControl.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;controls:MyCustomItem Width="Auto"
                                                   Command="{Binding DataContext.SelectedItemCommand,
                                                                     RelativeSource={RelativeSource FindAncestor,
                                                                                                    AncestorType={x:Type ItemsControl}}}"
                                                   CommandParameter="{Binding}"&gt;
                      &lt;controls:MyCustomItem.ContextMenu&gt;
                          &lt;ContextMenu&gt;
                              &lt;MenuItem Command="{Binding DataContext.ClearAlarmsCommand,
                                                          RelativeSource={RelativeSource FindAncestor,
                                                                                         AncestorType={x:Type ItemsControl}}}"
                                        Header="Clear All" /&gt;
                          &lt;/ContextMenu&gt;
                      &lt;/controls:MyCustomItem.ContextMenu&gt;
                  &lt;/controls:MyCustomItem&gt;
              &lt;/DataTemplate&gt;
          &lt;/ItemsControl.ItemTemplate&gt;
  </code></pre>