0

I am trying to center a WPF Window on the current position of the mouse cursor. Getting the mouse coordinates is no problem, but I need to determine the width and height of the window in order to calculate the offset for setting the 'Left' and 'Top' properties.

Is there a way to determine the width and height of a window before showing it (calling the 'Show' method)?

I have 'SizeToContent' set to true on my window so that the content determines the actual window size. I have already tried calling 'Measure' and was expecting this to set 'DesiredSize' but it didn't.

4

1 に答える 1

0

最初に Show() を呼び出してから、マウス カーソルの現在の位置を中央に合わせてみませんか?

于 2009-09-13T07:20:31.920 に答える