title: UserControl ContextMenu binding problem
body: <p>I have the following control:</p>
  
  <pre><code>&lt;UserControl x:Class="DNC_v3_0_Admin.Controls.FilterableTreeViewControl"
      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:Controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" 
      xmlns:Converters="clr-namespace:DNC_v3_0_Admin.Converters" 
      xmlns:Data="clr-namespace:System.Windows;assembly=System.Windows.Controls"
      xmlns:controlsInputToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
      mc:Ignorable="d"
      d:DesignHeight="300" d:DesignWidth="400" xmlns:my="clr-namespace:DNC_v3_0_Admin.Controls"
      x:Name="MyFilterableTreeViewControl"&gt;
  
      &lt;UserControl.Resources&gt;
          &lt;ImageBrush x:Key="PropertiesBrush" ImageSource="../Resources/machine.png"/&gt;
          &lt;Converters:ManagedObjectNodeIconConverter x:Key="TreeIconConverter"/&gt;
          &lt;Data:HierarchicalDataTemplate x:Key="FilterableTreeViewTemplate" ItemsSource="{Binding Children}"&gt;
              &lt;StackPanel Orientation="Horizontal" Height="Auto" Width="Auto" Grid.Row="0"&gt;
                  &lt;Image Source="{Binding NodeType,Converter={StaticResource TreeIconConverter}}"/&gt;
                  &lt;TextBlock x:Name="NameTextBlock" Text="{Binding Name}" controlsInputToolkit:ContextMenuService.ContextMenu="{Binding ElementName=MyFilterableTreeViewControl, Path=ContextMenu, Mode=TwoWay}" /&gt;
              &lt;/StackPanel&gt;
          &lt;/Data:HierarchicalDataTemplate&gt;
      &lt;/UserControl.Resources&gt;
  
      &lt;Grid x:Name="LayoutRoot" Background="White"&gt;
          &lt;Controls:TreeView Name="treeView" Style="{StaticResource MachineGroupStyle}" ItemsSource="{Binding ElementName=MyFilterableTreeViewControl, Path=ItemsSource}" SelectedItemChanged="treeView_SelectedItemChanged" /&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>The code behin:</p>
  
  <pre><code>    public ContextMenu ContextMenu {
          get {
              return ( ContextMenu )GetValue( ContextMenuProperty );
          }
          set {
              SetValue( ContextMenuProperty, value );
          }
      }
  
      public static readonly DependencyProperty ContextMenuProperty =
          DependencyProperty.Register( "ContextMenu", typeof( ContextMenu ), typeof( FilterableTreeViewControl ),
          new PropertyMetadata( null, new PropertyChangedCallback( FilterableTreeViewControl.OnContextMenuPropertyChange ) ) );
  
      private static void OnContextMenuPropertyChange( DependencyObject d, DependencyPropertyChangedEventArgs e ) {
          FilterableTreeViewControl ctrl = d as FilterableTreeViewControl;
          ctrl.OnContextMenuChange( ( ContextMenu )e.NewValue );
      }
  
      protected virtual void OnContextMenuChange( ContextMenu NewContextMenu ) {
          //ContextMenu = NewContextMenu;
      }
  </code></pre>
  
  <p>And the usage:</p>
  
  <pre><code>        &lt;my:FilterableTreeViewControl x:Name="machineGroupTreeView" Grid.Row="0" Grid.Column="0" ItemsSource="{Binding TreeRootNodes}" FilterCaption="Filter:" SelectedItemChanged="machineGroupTreeView_SelectedItemChanged" &gt;
              &lt;my:FilterableTreeViewControl.ContextMenu&gt;
                  &lt;controlsInputToolkit:ContextMenu&gt;
                      &lt;controlsInputToolkit:MenuItem Header="New" Command="{Binding NewCommand}" CommandParameter="{Binding Id}" &gt;
                          &lt;controlsInputToolkit:MenuItem.Icon&gt;
                              &lt;Rectangle Width="16" Height="16" Fill="{StaticResource PropertiesBrush}"/&gt;
                          &lt;/controlsInputToolkit:MenuItem.Icon&gt;
                      &lt;/controlsInputToolkit:MenuItem&gt;
                  &lt;/controlsInputToolkit:ContextMenu&gt;
              &lt;/my:FilterableTreeViewControl.ContextMenu&gt;
          &lt;/my:FilterableTreeViewControl&gt;
  </code></pre>
  
  <p>But the ContextMenu does not appear. Any idea?</p>