Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6323337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:29:53+00:00 2026-05-24T16:29:53+00:00

I understand that WPF coordinates are different from real screen coodinates (pixel coordinates) if

  • 0

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 want to (1) figure out which monitor a WPF window is on and (2) open another window in the bottom-left corner of the same monitor. I heard there is no equivalent of Screen for WPF so I use the WinForms version, as follows, which works fine at the default 96 DPI:

public void ChooseInitialPosition(Window w) // w is some other window
{
    var scr = System.Windows.Forms.Screen.FromRectangle(
          new System.Drawing.Rectangle((int)w.Left, (int)w.Top, (int)w.Width, (int)w.Height))
          .WorkingArea;

    this.Left = scr.Right - Width;
    this.Top = scr.Bottom - Height;
}

But at other DPIs, both steps work incorrectly, and may put the window completely off-screen.

So far, it looks like I can use Visual.PointToScreen for the first part:

var p1 = w.PointToScreen(new Point(0,0));
var p2 = w.PointToScreen(new Point(w.Width,w.Height));
var scr = System.Windows.Forms.Screen.FromRectangle(
    new System.Drawing.Rectangle((int)p1.X, (int)p1.Y, (int)(p2.X - p1.X), (int)(p2.Y - p1.Y))).WorkingArea;

I’m not sure if this is quite right, as it may not account for the borders correctly. But the second part is more important. How do I convert the screen rectangle “scr” into WPF space, in order to set Left and Top correctly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:29:55+00:00Added an answer on May 24, 2026 at 4:29 pm
    1. Which screen a WPF window is on:

      private static Screen GetScreen(Window window)
      {
         return Screen.FromHandle(new WindowInteropHelper(window).Handle);
      }
      
    2. 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;
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand that there are problems regarding running a WPF application from a console
I understand that there are several ways to blend XNA and WPF within the
What are the top 3 main concepts in WPF that you need to understand
I understand that requests are served by different threads, but do they all come
One thing i noticed about WPF is that it combines various concepts from other
In WPF Databinding, I understand that you have DataContext which tells an element what
I need to write some listViewItem ( using WPF ) - that contain image,
We have a WPF application that we want to convert to Silverlight. I understand
Note first of all that this question is not tagged winforms or wpf or
I understand that git diff compares a staged file and modified but not staged

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.