Sunday, October 5, 2014

XAML - Vertical & Horizontal GridSplitters

Often it's nice to allow the user to re-size segments of the screen.  WPF makes this possible with the GridSplitter class.   The MSDN documents are pretty clear on its usage with examples but here is another example I created in XamlPadX.

Horizontal & Vertical GridSplitter 

Beware, if you have a parent container that is scroll-able you will have trouble getting the GridSplitter to work correctly.   I made this mistake while working with PRISM.  Initially in the shell I wrapped my main content region with a ScrollViewer.  It seemed like a good idea at the time and I promptly forgot I'd done so.  While working in a module that loaded into the main content area, I noticed that my horizontal GridSplitter between two ListBox controls was not working correctly.  When adding items to the top list box, the grid splitter would be pushed down the screen.  Using WPF Inspector, I was able to find the issue with the ScrollViewer in the shell.

No comments:

Post a Comment