ApplicationMenu SplitButton shifted after upgrade from v19 to v22

Ribbon for WPF Forum

Posted 2 years ago by rex hui
Version: 22.1.2
Avatar

I figured out this has to do with the fact that we set the SystemParameters.MenuDropAlignment to false to ensure pop-up menus are always right aligned even on laptops.

This was not a problem on v19 but with the latest version (I think since v20), the SplitButton popup becomes shifted to the right.

https://ibb.co/sbDf7KX

Any idea how to fix this?

Thanks.

Comments (4)

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Normally Windows determines it by looking at the "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\MenuDropAlignment" registry key value, where:

  • 0 = Open to right (left-handed)
  • 1 = Open to left (right-handed)

The default on systems without a touchscreen is generally "0", while "1" might be the default on laptops with touchscreens.

I tested both registry values (rebooted in between) in our Ribbon / App Button Content QuickStart, and they seemed to open the app menu split button in the right spot in both cases.

Can you tell us how you are altering this setting, and how to reproduce it? 


Actipro Software Support

Posted 2 years ago by rex hui
Avatar

I use the code below to set it.

private static readonly FieldInfo _menuAlign = typeof(SystemParameters)
         .GetField("_menuDropAlignment", BindingFlags.NonPublic | BindingFlags.Static);

static MainWnd()
{
  if (_menuAlign != null)
  {
    EnsureStandardPopupAlignment(null, null);
    SystemParameters.StaticPropertyChanged += EnsureStandardPopupAlignment;
  }
}

private static void EnsureStandardPopupAlignment(object sender, PropertyChangedEventArgs e)
{
  if (SystemParameters.MenuDropAlignment)
    _menuAlign.SetValue(null, false);
}

My laptop is not a touchscreen, however, the registry key you mentioned still has a value of 1.

If you try add the above code, you will be able to reproduce the issue.

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Thanks for providing the code.  In some places we are also checking SystemParameters.IsMenuDropRightAligned so you would also need to update that value for this kind of reflection change to work with the current build.  That's why it worked some places but not others.

For the next maintenance release, we will consolidate usage of SystemParameters.IsMenuDropRightAligned to use MenuDropAlignment instead.


Actipro Software Support

Posted 2 years ago by rex hui
Avatar

Thanks. That seems to work.

But it is weird that I have to get the value first or otherwise setting it will not work.

if (SystemParameters.IsMenuDropRightAligned && 
   _isMenuDropRightAligned != null)
   _isMenuDropRightAligned.SetValue(null, false);

If I don't check for the value "SystemParameters.IsMenuDropRightAligned" first, just setting it does not work.

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.