A few months ago, Nick Thuesen posted his SpanningStackPanel class, which is basically a cross beween UniformGrid and StackPanel. Around that time, I was working on a project that called for exactly that layout.
Unfortunately, Nick’s panel didn’t work in my application because he was modifying the Children collection in his code, which is a big no-no if you want to support databinding (e.g. in order to use it as the ItemsPanel within a ListBox). I ended up writing my own version, adding a few features that were required for the project.
At Mix, I promised Nick I’d post and get him the fixed source code. You can download the source (plus some basic tests) in the first version of the Fortes Panel Pack (currently “Pack” is a misnomer, since there’s only one — but I have a few more waiting to be packaged for external consumption).
Features / Release Notes:
- All the features of Nick’s original
- Support for data-bound children
- Special support for
Expanderchildren: Detects collapsedExpanderelements and treats them as fixed-size elements - Bug: Support for
Expanderwithin aTemplatedoes not lay out correctly on the first pass — see theDataBoundPanels.xamlfile in the sample project. Resizing the window, or any other action that causes a relayout, fixes the issue. (I’ll fix it in the next release)