【问题标题】:WPF popup control placement on two monitors setup with different resolutionWPF 弹出控件放置在具有不同分辨率的两台显示器上
【发布时间】:2016-03-01 19:53:17
【问题描述】:

我在我的开发机器上使用了两个不同分辨率的显示器。分辨率较小的显示器被配置为主显示器。如果我在辅助显示器上最大化我的 WPF 应用程序并在底部显示一个弹出控件,它会重新定位:

我猜,框架使用主显示器的较低分辨率来检查弹出窗口是否必须重新定位。 WPF 框架不检查当前显示分辨​​率还是我必须自己配置?

【问题讨论】:

    标签: wpf popup multiple-monitors


    【解决方案1】:

    要在两个显示器上重新定位弹出控件,最好根据MainWindow的PointToScreen属性设置弹出控件水平垂直偏移

    var mousePosition = Mouse.GetPosition(Application.Current.MainWindow);
    var pointToScreen = Application.Current.MainWindow.PointToScreen(mousePosition);

    _popup.Horizo​​ntalOffset = pointToScreen.X;
    _popup.VerticalOffset = pointToScreen.Y;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-17
      • 2014-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-26
      • 1970-01-01
      相关资源
      最近更新 更多