Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I just moved my PC to Windows 8 from Windows 7 and while running our WPF application I noticed that our WPF popups and/or tool tips are now in the lower-left by default instead of the normal lower right. Has anyone noticed this? I know you can specify their location on each tooltip in the xaml, but we have a lot of tool tips and popups. I want to know if there is a way to specify the default location globally in a WPF app. Google hasn't yielded many results on this subject. We have a reason to keep them in the same original default position (some popups have content relative to their start up position).

Windows 8: (Lower left)

Tool Tip on Win8

Windows 7: (Lower right)

Tool Tip on Win7

Same code! Standard "tooltip" xaml attribute.

Any ideas?

RESOLVED AND I POSTED THE COMMENTS


Ok, I have found the issue. It has to do with Tablet PCs/Touchscreens. (left handed.. right handed preference) This other link provided a reason. I am working on a solution to resolve this now. Ill post up the details soon!

windows 8 popup location

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
294 views
Welcome To Ask or Share your Answers For Others

1 Answer

Thanks @TravisWhidden for the solution. Just implemented an improved version of it that listens to the StaticPropertyChanged event, I'll paste it in here because it seems less of a "hack".

private static readonly FieldInfo _menuDropAlignmentField;
static MainWindow()
{
    _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);
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...