Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>ContextMenu is a popup and as such it has the FocusScope attached property set to true:</p> <p>From <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.focusmanager.isfocusscope.aspx" rel="nofollow noreferrer">MSDN</a></p> <blockquote> <p>A focus scope is a container element that keeps track of the FocusManager..::.FocusedElement within the its scope. By default, the Window class is a focus scope as are the Menu, ContextMenu, and ToolBar classes. An element which is a focus scope has IsFocusScope set to false.</p> </blockquote> <p>Basicly it also tells commands to stop looking any further in the visual tree.</p> <p>So you have two options</p> <ol> <li><p>Set the <code>FocusManager.IsFocusScope="True"</code> on your context menu object</p> <p></p></li> <li><p>Or move your Command bindings so that your are bound to the ContextMenu in stead of the UserControl like so:</p></li> </ol> <p>Code sample:</p> <pre><code>&lt;ContextMenu FocusManager.IsFocusScope="False"&gt; &lt;ContextMenu.CommandBindings&gt; &lt;CommandBinding Command="Zoom" Executed="ExecuteZoom" CanExecute="CanZoom"/&gt; &lt;/ContextMenu.CommandBindings&gt; &lt;MenuItem Command="Zoom"/&gt; &lt;/ContextMenu&gt; </code></pre> <p>Hope this helps! :)</p> <p>Some FocusScope nightmare tales from the field on the interwebs:</p> <ul> <li><a href="http://blogs.msdn.com/ebooth/archive/2006/08/31/732609.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/ebooth/archive/2006/08/31/732609.aspx</a></li> <li><a href="http://pointlessly.blogspot.com/2007/11/wpf-routed-commands-and-focus-scope.html" rel="nofollow noreferrer">http://pointlessly.blogspot.com/2007/11/wpf-routed-commands-and-focus-scope.html</a></li> <li><a href="http://social.msdn.microsoft.com/forums/en-US/wpf/thread/f5de6ffc-fa03-4f08-87e9-77bbad752033/" rel="nofollow noreferrer">http://social.msdn.microsoft.com/forums/en-US/wpf/thread/f5de6ffc-fa03-4f08-87e9-77bbad752033/</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload