title: Context Menu Binding to Parent Window's Datacontext
body: <p>I have a TreeListControl that binds to a collection in my VM. I also want to define the context menu inside the treelistcontrol having its header text bind to another string in my VM. how can I set the data context in this case? I tried to </p>
  
  <pre><code>&lt;Window.DataContext&gt;
      &lt;model:ViewModel&gt;&lt;/model:ViewModel&gt;
  &lt;/Window.DataContext&gt;
  &lt;Grid&gt;
  &lt;Button Grid.Row="1"  Command="{Binding CellCheckedCommand}"&gt;&lt;/Button&gt;
  
      &lt;TextBlock Text="{Binding HeaderText}" Grid.Row="2"&gt;
          &lt;TextBlock.ContextMenu&gt;
              &lt;ContextMenu&gt;
                  &lt;MenuItem DataContext="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}, Path=DataContext}"  Header="{Binding HeaderText}"&gt;&lt;/MenuItem&gt;
              &lt;/ContextMenu&gt;
          &lt;/TextBlock.ContextMenu&gt;
      &lt;/TextBlock&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>but it doesn't work. </p>
  
  <p>Here is the ViewModel</p>
  
  <pre><code>public DelegateCommand CellCheckedCommand { get; set; }
  
  private String _HeaderText;
  
  public String HeaderText 
  {
      get
      {
          return _HeaderText;
      }
      set
      {
          _HeaderText = value;
          NotifyPropertyChanged("HeaderText");
      }
  }
  
  public void NotifyPropertyChanged(String name)
  { 
      if(PropertyChanged != null)
      {
          PropertyChanged(this, new PropertyChangedEventArgs(name));
      }
  }
  
  private void CellCheckedMethod()
  {
      HeaderText = "Changed";
  }
  </code></pre>