I understand that WPF coordinates are different from \"real\" screen coodinates (pixel coordinates) if the computer is not using the default DPI setting. In my program I wan
Which screen a WPF window is on:
private static Screen GetScreen(Window window)
{
return Screen.FromHandle(new WindowInteropHelper(window).Handle);
}
Open another window in the bottom-left corner of the same screen:
static Point RealPixelsToWpf(Window w, Point p)
{
var t = PresentationSource.FromVisual(w).CompositionTarget.TransformFromDevice;
return t.Transform(p);
}
private static void SetPositionBottomLeftCorner(Window sourceWindow, Window targetWindow)
{
var workingArea = GetScreen(sourceWindow).WorkingArea;
var corner = RealPixelsToWpf(sourceWindow, new Point(workingArea.Left, workingArea.Bottom));
targetWindow.Left = corner.X;
targetWindow.Top = corner.Y - targetWindow.ActualHeight;
}