title: WPF ContextMenu doesn't see dependancy property of user control
body: <p>I have a user control (named mUserControl) with some textboxes, content of which is bounded to properties of a class (model), named Module. The user control itself has one custom dependancy property (ItemSource) of type Module. So I can bind content of textboxes to properties of the Module.  </p>
  
  <p>This user control is a part of a bigger View (HomeScreenView). I get easily access to ItemsSource from HomeScreenViewmodel. Everything works fine except a ContextMenu on textboxes. I get a binding error. ContextMenu doesn't see the ItemsSource property of the user control, whilst all other elements do that. I know, ContextMenu is on different visual tree. I've tried different ways to get this work, with no success. Any suggestions are welcome!</p>
  
  <p>UserControl xaml (simplified for clarity):</p>
  
  <pre><code>&lt;UserControl x:Class="xxx.Views.ModuleFrameView"
  x:Name="mUserControl"&gt;
  &lt;Grid&gt;
  &lt;TextBox x:Name="txt5" Text="{Binding ItemSource.Ch1SET, 
  ElementName=mUserControl}" IsEnabled="{Binding ItemSource.IsEnbl_5, 
  ElementName=mUserControl}" IsReadOnly="True"                        
  TextAlignment="Center" ContextMenuService.ShowOnDisabled="True"
  Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"&gt;
  &lt;TextBox.ContextMenu &gt;
       &lt;ContextMenu Name="cm"&gt;
               &lt;MenuItem Header="Enable" cal:Message.Attach="cmEnable($source)" IsCheckable="True" IsChecked="
  {Binding Path=PlacementTarget.Tag.DataContext.ItemSource.IsEnbl_5, 
  RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=TextBox}}"/&gt;
       &lt;/ContextMenu&gt;
  &lt;/TextBox.ContextMenu&gt;
  &lt;!--...--&gt;
  </code></pre>
  
  <p>ModuleFrameView has an ItemSource property defined in code-behind file:</p>
  
  <pre><code>public Module ItemSource
      {
          get { return (Module)GetValue(ItemSourceProperty); }
          set { SetValue(ItemSourceProperty, value); }
      }
  
      public static readonly DependencyProperty ItemSourceProperty =
      DependencyProperty.Register("ItemSource", typeof(Module), typeof(ModuleFrameView), new PropertyMetadata(default(Module)));
  </code></pre>
  
  <p>This DP of type Module:</p>
  
  <pre><code>public class Module : PropertyChangedBase
  {
      private string _ch1SET;
      public string Ch1SET
      {
          get { return _ch1SET; }
          set
          {
              if (_ch1SET == value) return;
              _ch1SET = value;
              NotifyOfPropertyChange(() =&gt; Ch1SET);
          }
      }
  private bool _isEnbl_5;
      public bool IsEnbl_5
      {
          get { return _isEnbl_5; }
          set
          {
              if (_isEnbl_5 == value) return;
              _isEnbl_5 = value;
              NotifyOfPropertyChange(() =&gt; IsEnbl_5);
          }
      }
  //...
  //...lot of properties
  </code></pre>
  
  <p>Second user control (above mentioned bigger View)'s xaml:</p>
  
  <pre><code>&lt;UserControl x:Class="xxx.Views.HomeScreenView"&gt;
  &lt;Grid&gt;
      &lt;ContentControl&gt;
  &lt;loc:ModuleFrameView Grid.Row="0" Grid.Column="0" ItemSource="{Binding ModuleArr[0]}"/&gt;
  &lt;loc:ModuleFrameView Grid.Row="0" Grid.Column="1" ItemSource="{Binding ModuleArr[1]}"/&gt;
  &lt;!--...--&gt;
  </code></pre>