dotnet / dotnet/wpf

[API Proposal] System.Windows.WindowStartupMonitor

Open
#6,841 21 comments 2 reactions 0 assignees View on GitHub
API suggestion
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

In times of multi monitor setup I would like to propose a new API that allows us to set the startup monitor of the window. I am open for naming changes. The reason is that many developers would prefer to use the WindowStartupLocation.CenterScreen but only change the monitor from the monitor on which the mouse is currently located to a fixed monitor.

The way to do this ourselves is tedious. Enumerating all screens, calculating the center, use WinAPIs to move the window. `WindowStartupMonitor` could be an integer which stands for the index of the monitor. By default it could be `-1` which means "the monitor on which the mouse is currently located".

Ideas? Suggestions?

Edit: based on the discussion and all the mentioned problems this proposal has been changed to provide a way to set the startup monitor to the primary monitor (instead of the current behavior of "screen that contains the mouse cursor").

```diff
namespace System.Windows
{
public class Window
{

+ [DefaultValue(WindowStartupMonitor.Cursor)]
+ public WindowStartupMonitor WindowStartupMonitor
+ {
+ get {...}
+ set {...}
+ }

}

+ public enum WindowStartupMonitor
+ {
+ Cursor = 0,
+ Primary = 1
+ }

}


```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.