You can use WindowInteropHelper
to get a handle of your window. Then use the Screen.FromHandle
method to obtain the Screen which offers more information like Bounds, BitsPerPixel, etc..
The Screen.FromHandle method works as stated by the docs:
A Screen for the display that contains the largest region of the
object. In multiple display environments where no display contains any
portion of the specified window, the display closest to the object is
returned.
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Interop;
namespace WpfApp2
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private readonly WindowInteropHelper _windowInteropHelper;
public MainWindow()
{
InitializeComponent();
_windowInteropHelper = new WindowInteropHelper(this);
LocationChanged += OnLocationChanged;
}
private void OnLocationChanged(object sender, EventArgs e)
{
Screen screen = Screen.FromHandle(_windowInteropHelper.Handle);
Debug.WriteLine($"IsPrimary: {screen.Primary}, Bounds: {screen.Bounds}");
}
}
}
If you want to get rid of System.Windows.Forms you need to write your own Wrapper class around the Multiple Display Monitors Functions