title: CommandParameters in ContextMenu in WPF
body: <p>I have a scenario where I have a WPF TreeView control that has an <code>HierarchicalDataTemplate</code> for its items. Now inside the <code>HierarchicalDataTemplate</code>, I have a <code>Label</code> and the <code>Label</code> has a <code>ContextMenu</code> with a menuitem for <code>Delete</code>. The Delete menuitem is bound to a Command called <code>DeleteCommand</code> which is a part of the class that has been set as the <code>DataType</code> of the <code>HierarchicalDataTemplate</code>. </p>
  
  <p>Now, I want to pass the <code>TreeView</code> control in the <code>CommandParameters</code> of the ContextMenu's <code>Delete</code> menuitem's <code>DeleteCommand</code> so that I can handle the selection of the TreeViewItems on the deletion of the currently selected item.</p>
  
  <p>But if I bind the <code>CommandParameters</code> as the <code>{Binding ElementName=TreeViewName}</code> or whatever for that matter, it is always null unless the binded element is a property in the <code>DataContext</code>.</p>
  
  <p>Can anyone help me with a solution because I think, I have tried all the possible things such as RelativeSource and AncestorType etc but its always null. To me, it looks like either a limitation or a bug in the framework.</p>