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
2010-06-23 06:40:05
+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
2010-06-23 06:52:19
The only drawback is that it is post handling.
Veer
2010-06-23 09:43:31
True. But in most cases I suspect it will be fast enough that the user doesn't notice.
Daniel Rose
2010-06-23 10:55:54
+1
A:
If you set the MinHeight and MaxHeight attributes of the window to the desired height the window will have a fixed height