WPF resizing and gridsplitter issues

Sep 17, 2008 11:14

Maybe some of the WPF users who read my LJ can help. If not, at least I get to rant.

Here are the problems:
  1. GridSplitter only really works right if everything is using star sizing.
  2. GridSplitter likes to ignore the minimum sizes you have set on columns.
  3. If you are using a GridSplitter between a pixel-sized column and a star-sized column, when you drag, rather than the GridSplitter stopping when it hits the star-sized column's MinWidth, it will keep going and resize the grid so it's bigger than your window such that you can push all of the star-sized column off the window entirely.
  4. The obvious solution would be to bind your Grid's width and height to the Window's width and height (since of course having its HorizontalAlignment and VerticalAlignment set to Stretch doesn't fix this problem). But wait! What about the window frame? Okay, you say, I will bind the Grid's width and height to the Window's client width and height. Sounds easy enough. EXCEPT THERE IS NO EASY WAY TO GET THE WINDOW'S CLIENT AREA. This was incredibly simple to do in WinForms, but nearly impossible in WPF. In fact, the solution I have seen proposed is to actually do a pinvoke of the Win32 function for GetClientRect.
  5. Windows do not respect the minimum sizes of their content. For example, if I have a Window and in it I have a Grid, and my Grid has MinWidth and MinHeight set, I can still resize my Window down to nothing. Note that attempting to bind the Window's MinWidth and MinHeight to the Grid's encounters issues because of the window frame too.

Gaaaaaah. Apparently the "correct" solution to at least the GridSplitter problems is to create a custom GridSplitter that will magically work right. Too bad nobody posted their code online, and I am left flailing trying to figure out what I need to do in my GridSplitter to make it work!

wpf

Previous post Next post
Up