I am trying to implement what is in effect a modal popup in WPF.
I have done this with a transparent window and ShowDialog(). The window can be triggered by any one of several hundred controls in a matrix (dm in the example below). dm[r,c].tb is in fact a TextBox control.
The following code should have done the trick just fine:
var location = dm[r, c].tb.PointToScreen(new Point(0, 0));
popupWindow.Left = location.X;
popupWindow.Top = location.Y - popupWindow.Height;
popupWindow.ShowDialog();
In fact, the window was displaying to the right of and below the control, further away the more the control was down or to the right in the main window.
It took me a while to realize that it was in fact offset by a factor of exactly 1.5, and the reason is that, being severely sight-impaired, I run my machine with a magnification of 150% using the ease of access setting.
The code is easily rectified to account for this on my machine:
var location = dm[r, c].tb.PointToScreen(new Point(0, 0));
popupWindow.Left = location.X/1.5;
popupWindow.Top = location.Y/1.5 - popupWindow.Height;
popupWindow.ShowDialog();
This delivers correct results on my machine, but how do I grab the ease of access magnification factor to make it work whatever magnification people are using?