-1

For example, sample button is located at the top right corner of the monitor and button is cut off because it is outside the window.

enter image description here

In this state, press the button to call OpenFileDialog.ShowDialog().

enter image description here

Then, OpenFileDialog is automatically created inside, not outside the window. This automatic positioning is applied automatically even when there are two or more monitors. How can I apply this automatic positioning to my custom dialog? Currently, in my code the mouse position is used so that the custom dialog appears at the clicked position, but it is cut off when it is created at the window screen border line. (My dialog inherits the Window class.)

wddfrwd
  • 53
  • 4
  • Yes. The answer was to use the CenterOwner property and set the Owner property to 'this' keyword. The position is fixed to the middle of the window, but I think I can do this part. Thanks. – wddfrwd Jul 13 '20 at 15:42

1 Answers1

-1

Use Window.WindowStartupLocation Property.

  • Manual causes a window to be positioned according to its Left and Top property.
  • CenterScreen causes a window to be positioned in the center of the screen that contains the mouse cursor.
  • CenterOwner causes a window to be positioned in the center of its owner window
Dean Kuga
  • 11,878
  • 8
  • 54
  • 108