WPF multi display and DPI

LuddyNiceBloke 1 Reputation point
2021-02-04T08:27:24.78+00:00

I have developed a countdown app to display a timer on a comfort monitor, full screen, for speakers at conferences. Normally, the resolution of the work laptop screen running the program and second monitor have resolutions 1920 x 1080, the app works fine. However, when I use my personal laptop with screen at 3840 x 2160 resolution I cannot get the counter to display on the second monitor, it opens always on the laptop, main monitor. The code I have used:

                    Screen secondaryScreen = Screen.AllScreens[1];
                    rightWin = new ExtendedDisplay()
                    {
                        WindowStartupLocation = WindowStartupLocation.Manual,
                        WindowState = System.Windows.WindowState.Normal,
                        Left = secondaryScreen.WorkingArea.Left,
                        Top = secondaryScreen.WorkingArea.Top,
                        Width = secondaryScreen.WorkingArea.Width,
                        Height = secondaryScreen.WorkingArea.Height
                    };

                    rightWin.DataContext = vm;
                    rightWin.Show();
                    rightWin.WindowState = WindowState.Maximized;
                    rightWin.Owner = this;

I see that by changing the DPI on my laptop from 250% to 100% or 125% the App works correctly, the counter displays on the extended monitor. From 150% upwards, I am back to having the counter showing on my laptop screen. I am not sure how to manage this. In the future, I will want to add a third monitor so I need to understand what is happening. Thanks

Developer technologies Windows Presentation Foundation
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ken Tucker 5,861 Reputation points
    2021-02-04T10:37:07.153+00:00

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.