3

I have a WPF desktop app. I've gotten reports from W8 users that the code completion window in our app is not aligned correctly. I investigated and found out that its a setting in W8 tablet settings that conflicts with the placement of popups in wpf

Tablet settings

Default is right handed and then the code completion popup looks like this enter image description here

When changed to left handed the code completion popup renders correctly like this enter image description here

Is there a way to programmaticly force the app to use left handed settings, or ignore it completely so it renders like in w7?

edit: Got an upwote so can update with solution, requires .NET 4.5

private static readonly FieldInfo MenuDropAlignmentField;

static MyWindow()
{
    MenuDropAlignmentField = typeof (SystemParameters).GetField("_menuDropAlignment",
        BindingFlags.NonPublic | BindingFlags.Static);
    System.Diagnostics.Debug.Assert(MenuDropAlignmentField != null);

    EnsureStandardPopupAlignment();
    SystemParameters.StaticPropertyChanged += (s, e) => EnsureStandardPopupAlignment();
}

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

Full code here

https://github.com/AndersMalmgren/FreePIE/blob/master/FreePIE.GUI/Shells/MainShellView.xaml.cs

Anders
  • 17,306
  • 10
  • 76
  • 144

0 Answers0