December 1, 2011 Leave a comment
By default, child elements in a WrapPanel size to fit the largest item on a particular row or column (if their alignment is set to Stretch), or align themselves relative to the largest item on the row or column.
In the example below, the label with 3 lines makes the entire row larger. But the second row is shorter because all of the labels in that row just have a single line.
You can make all of the child elements in a WrapPanel the same height by setting the WrapPanel’s ItemHeight property to some fixed value.
<WrapPanel Orientation="Horizontal" ItemHeight="60"> <Label Background="AliceBlue" Content="William I" VerticalAlignment="Center"/> <!-- etc -->
You can also set a consistent item width using the ItemWidth property.