That’s a WrapPanel and I am outta here… [A balanced WrapPanel implementation for Silverlight and WPF!]

This blog has moved to a new location and comments have been disabled.

All old posts, new posts, and comments can be found on The blog of

See you there!

Comments (5)
  1. Torsten says:

    I was expecting a balanced Wrap Panel that would make columns or rows equally long (depending on the orientation).

    In your example you have 15 elements in your wrap panel. This would result in 3 rows or 3 columns of 5 items each.

    Would that kind of balancing be just as easy to implement?

  2. David Anson says:


    That seems like it would be fairly straightforward. In fact, I bet you could use my BandedStackPanel to do exactly that:…/this-one-time-at-band-camp-a-banded-stackpanel-implementation-for-silverlight-and-wpf.aspx

    Hope this helps!

  3. Ronnie says:

    Hi, this is great stuff. I have a query though, the post is pretty old but hoping for the best..

    I'm using this as ItemsPanelTemplate of a listbox. I need to make changes to this so that the items in the panel increase/decrease their size a little to use up all the slack space. I tried to change the values that go into the element.Arrange() call but that changes the ListBoxItem's size, but not the size of the control sitting as the item. My listbox has a button in the ItemTemplate. Any suggestions on what I should do?


  4. David Anson says:


    I think what you want is to set ListBox.ItemContainerStyle to a Style/TargetType=ListBoxItem with a Setter/HorizontalContentAlignment=Stretch. That'll tell the ListBoxItem wrapper to stretch its content which it sounds like it isn't doing at the moment.

  5. jl says:

    I'm late for the party but just want to say this is good stuff! 🙂

Comments are closed.

Skip to main content