wpf: Can a Grid splitter be used ouside of a grid?

Mr Snug picture Mr Snug · May 13, 2009 · Viewed 7.4k times · Source

I've got a StackPanel, and it's perfect for laying out columns that the user adds at runtime. But I'd like the columns to be resizable, and I was reading about the GridSplitter control. Here's what I'm wondering: Is the GridSplitter the wpf replacement for the WinForms splitter? In other words, is this the de facto way to allow the users to resize regions of the window? Does it only work inside of a Grid? If I have items inside a stackpanel or a dockpanel, can I still use a gridsplitter the way I used the splitter in WinForms? If I have to use a Grid, how can I make it behave just like a StackPanel? (hope it doesn't come to that)

Answer

Wallstreet Programmer picture Wallstreet Programmer · May 13, 2009

GridSplitter only works in a Grid and is the easiest way to allow users to resize controls. What do you mean that you want your grid (with gridsplitters) to behave just like a stackpanel? A stackpanel will exactly fit each of its children while a grid with gridsplitters will leave it up to the user.