小编Che*_*usk的帖子

无法在辅助监视器中创建WPF窗口

我正在努力在应用中实现一些类似Chrome的标签功能,并且在使新实例正确生成时遇到一些麻烦.我已经做了很多搜索和迭代各种解决方案,但还没有能够在第二台显示器上生成一个新的窗口.

这是使用线程:

  1. 打开文件
  2. 将当前选项卡拖到其他监视器
  3. 新的应用程序实例在其中设置了该选项卡,在用户将选项卡拖动到的位置生成.

断开连接在步骤3中.新实例始终在主监视器上生成.

所以,一些代码可以扩展问题.

namespace app {
    public class AppView {
      public void OpenInNewWindow()
      {
        // Create a new viewmodel
        var appViewModel = new AppVM();

        //// On my machine this returns the correct screen "DISPLAY2".  The Top and Left properties are 0 and 1680, respectively.
        var targetScreen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);

        ////So we can set the position of the new view
        var appView = new AppView(appViewModel);

        //This seats the currently selected data tab inside the new AppViewModel
        RelocateSelectedViewModel(appViewModel);

        appView.WindowStartupLocation …
Run Code Online (Sandbox Code Playgroud)

c# wpf user-interface

5
推荐指数
1
解决办法
3958
查看次数

标签 统计

c# ×1

user-interface ×1

wpf ×1