Jonas
Jonas

Reputation: 311

WPF Window resizing in a different direction

I am having trouble making my WPF window resize in a different direction. Currently, when I shoot an event in my application, application resizes down (I make an element visible and then WPF window automatically resizes). I would like that my application would instead resize up, so that the application would not become hidden by a taskbar. How does one do that?

Below is a picture explaining my problem. Picture 1 shows small window. Picture 2 shows the problem, where window resizes beyond the screen. Picture 3 shows what I want to do.

I can surely code this resizing in my code, where I would move the window, but is there not a nice way in WPF?

enter image description here

Upvotes: 1

Views: 1069

Answers (1)

Stefan Over
Stefan Over

Reputation: 6046

Changing the Width or Height property of your window will always change the layout of it to the right or bottom.

The Left and Top property of the window determine the X- and Y-Offset of your window relative to the top-left corner of your screen.

To achieve your goal, you have to do 2 steps:

  • Increase the window Height by the amount of X
  • Decrease the window Top by the amount of X

Upvotes: 1

Related Questions