tags:

views:

34

answers:

3

I want to only allow my WPF window to be resized horizontally. How best can I achieve this?

+4  A: 

It's kind of a pain. Basically you need to set up a hook function to process windows messages. Then you would catch the WM_SIZING (0x0214) message and modify the parameters so that the horizontal dimension could not be changed.

Pete Brown also has some great info on this topic on his blog.

Josh Einstein
+1  A: 

You could try databinding to the size of the window, and then setting the size back to the old value whenever the vertical dimension is changed.

Daniel Rose
The only drawback is that it is post handling.
Veer
True. But in most cases I suspect it will be fast enough that the user doesn't notice.
Daniel Rose
+1  A: 

If you set the MinHeight and MaxHeight attributes of the window to the desired height the window will have a fixed height

Works a treat...so obvious when you think about it. Thanks
David Ward