.net - WPF弹出窗口的习惯

标签 .net wpf xaml windows-8 tooltip

我刚刚将PC从Windows 7移至Windows 8,并且在运行WPF应用程序时,我注意到WPF弹出窗口和/或工具提示现在默认位于左下角,而不是通常的右下角。有人注意到吗?我知道您可以在xaml中的每个工具提示上指定它们的位置,但是我们有很多工具提示和弹出窗口。我想知道是否可以在WPF应用程序中全局指定默认位置。 Google在这个问题上并未取得很多成果。我们有理由将它们保持在相同的原始默认位置(某些弹出窗口具有相对于其启动位置而言的内容)。

Windows 8 :(左下方)



Windows 7 :(右下方)



相同的代码!标准的“工具提示” xaml属性。

有任何想法吗?

解决,我发表了评论



好的,我发现了问题。它与Tablet PC /触摸屏有关。 (左手..右手首选项)此其他链接提供了一个原因。我正在研究一种解决方案,现在可以解决此问题。病态很快就会贴出来!

windows 8 popup location

最佳答案

感谢@TravisWhidden提供解决方案。刚刚实现了侦听StaticPropertyChanged事件的改进版本,因此将其粘贴到此处,因为它看起来不像是“黑客”。

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);
    }
}

关于.net - WPF弹出窗口的习惯,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18113597/

相关文章:

.net - 如何强制对系统类型使用自定义 UITypeEditor

c# - 我如何构建可以执行用户定义的规则引擎,如果在 C#.net 中有其他规则

c# - Orchard CMS 部分放置

wpf - 覆盖一般按钮样式

c# - 为什么使用 DataTemplates 时 ViewModel 的 ObservableCollection 没有显示在 View 中?

c# - 使 XSLT 语言独立

WPF 工作目录

wpf - 生成的 Xaml 代码和自定义 C# 代码不会产生相同的输出?

c# - 某些属性名称的 WPF 绑定(bind)问题

c# - WPF 控件初始化时未更新属性