I have a ListBox whose ItemsPanel I have replaces with a WrapPanel. The WrapPanel now hosts the databound ListboxItems. Each item has a variable sized text in it, giving each item a different width. However, I want the width to be constant so that all items have the same width as the item with the longest text. Is that possible?
Asked
Active
Viewed 9,106 times
1 Answers
20
Place each item in a single-row, single-column (auto width) grid, and name the column. Set Grid.IsSharedSizeScope on the ListBox and all grids will have the same width.

Timores
- 14,439
- 3
- 46
- 46
-
1+1. With this, I could take the final leap with changing my gui from a (horizontal) `StackPanel` inside a `ScrollViewer`, with variable size items, into a `WrapPanel` with all items sharing the same size. Really great stuff. – Christoffer Lette Mar 01 '11 at 22:59
-
The effect is marvelous...even if it feels like a bit of a hack, it beats making a new custom control for this crap...hehe – Assimilater Jul 25 '17 at 21:15
-
2Here's a [how-to](https://stackoverflow.com/questions/23524453/wrappanel-trying-to-make-the-itemwidth-equal-to-the-max-width-of-any-one-elemen?noredirect=1&lq=1) – mcalex Mar 23 '20 at 08:29