(Print this page)

Menus opening on the "wrong" side
Published date: Tuesday, February 3, 2015
On: Moer and Éric Moreau's web site

I just noticed that menus of many applications are opening on the wrong side. Have a look at the Calculator on a system not configured for lefty!

It was disturbing to me and I found why it does that. Apparently, Microsoft decided to do that on touch-capable devices. Now that I know the reason, I may understand why.

If you want to change this behavior, you can change the value of the MenuDropAlignment from the Registry (HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows) by setting it to 0.

Or if you would just like to change the behavior in your application (which is a bit strange when you compare to other apps on the same computer), you can use a little snippet like this one (taken from a C# WPF application - App.xaml.cs):

    private static readonly FieldInfo _menuDropAlignmentField;
    static App()
    {
        _menuDropAlignmentField = typeof(SystemParameters).GetField("_menuDropAlignment", BindingFlags.NonPublic | BindingFlags.Static);
        System.Diagnostics.Debug.Assert(_menuDropAlignmentField != null);

        EnsureStandardPopupAlignment();
        SystemParameters.StaticPropertyChanged += SystemParameters_StaticPropertyChanged;
    }

    private static void SystemParameters_StaticPropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        EnsureStandardPopupAlignment();
    }

    private static void EnsureStandardPopupAlignment()
    {
        if (SystemParameters.MenuDropAlignment && _menuDropAlignmentField != null)
        {
            _menuDropAlignmentField.SetValue(null, false);
        }
    }

(Print this page)