Skip past navigation, straight to the content

UniformPanel

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 Expander children: Detects collapsed Expander elements and treats them as fixed-size elements
  • Bug: Support for Expander within a Template does not lay out correctly on the first pass — see the DataBoundPanels.xaml file 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)

One Comment

  1. So I looked at my code and, thankfully, I’m not modifying the children in the custom panel. (I was surprised to find out I was doing as such.) It seems that the RowDefinitions and ColumnDefintions are ReadOnly when the panel is used in a ItemsPresenter’s ItemsPanel property. I didn’t dig deeper to find out why though. I’d like to find out though. Curious as to why a panel (Grid) can’t add/remove columns and rows to itself in this situation.

    Posted Jun 10, 2007 at 7:19pm | Permalink

One Trackback/Pingback

  1. Posted May 21, 2007 at 8:18am | Permalink

    […] 05/21/07 EDIT: Fil Fortes was kind enough to point out I’ve put up a non-bindable panel. If you want a good version of this panel you should check out: http://fortes.com/2007/05/07/uniformpanel/ […]