Recently working on the UI of a WPF project I struggled attempting to get the Right Click Context Menu to appear as normal, to the right and below the mouse pointer. No matter what options I used with ContextMenu (.Placement and .PlacementRectangle) the Context Menu would appear to the left and down instead of the right and down.
I spent a few hours researching, testing, debugging, no matter what I couldn’t get the context menu to appear to the right. I then enlisted the help of some other developers at the .Net Framework Developer Center forums and learned I was making the correct assumptions and doing the right things but it was still not working. Link to forum thread.
I then noticed that the positioning of the Context Menu was not consistent with all applications on my system. I am using a Fujitsu Lifebook Tablet PC, running Windows 7. Most of the apps I use daily, Visual Studio 2010, Chrome, FireFox, AIM to name a few all had context menu normally to the right and down from the mouse pointer. But Explorer, Microsoft Office, Internet Explorer for example all had the context menu to the left and down.
Further research on Google finally revealed that Windows 7 had a registry key that would determine if the context menu appeared to the right or left. And more importantly Windows 7 had control panel settings specific to a Tablet PC.
The default “Right-handed” user on a tablet would set the context menu to the left for easier access while using the actual tablet surface instead of using a mouse like a normal laptop. This, I assume, would make it easier to select items from the context menu for a right handed user. Unfortunately it was an unknown distraction that took several hours to track down.
Clearly Chrome, FireFox and Visual Studio 2010 have found a way around this Registry key, or they work around it some how, but I have yet to find a way with WPF.
Tags: