Sunday, October 12, 2008   Search 
Links

 

Disciple
 A trigger for the MenuItem directly under the mouse (deja vu) Minimize
Location: BlogsAsk Dr. WPF    
Posted by: Dr. WPF 11/6/2007 6:02 AM

By (indirect) request, I have put together a helper class that provides a property that can be used as a trigger to determine if a MenuItem is directly under the mouse.  This is analogous to this solution offered by Mike Hillberg for dealing with the TreeViewItem directly under the mouse. 

Mike does a good job of explaining the general problem and solution, so I highly recommend that you read his post!

The MenuItem scenario has its own set of issues to overcome, most of which arise from the fact that submenu items are very often disabled (due to application state).  Things are further complicated by the fact that the subitems are presented within a Popup.  I will leave it as an exercise for the reader to review my approach to see how I dealt with these issues (because I'm just too lazy to explain myself right now ).

Here is the code for the MenuHelper class (open source, as always) and here is a sample app that demonstrates its usage.  Note that the sample class randomly disables menu items to simulate the changing state of an application.

Hope this is useful.  Let me know if you encounter any issues with the helper class.

Cheers,
Dr. WPF

Permalink |  Trackback

Comments (1)   Add Comment
Re: A trigger for the MenuItem directly under the mouse (deja vu)    By DaveAtDotNetCodeSlingers on 11/6/2007 8:18 AM
Excellent - thanks!!!


Your name:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment   Cancel 

  
Copyright 2007 by Dr. WPF   Terms Of Use  Privacy Statement