How can I make a column in a listbox in WPF the same width for all items? How can I make a column in a listbox in WPF the same width for all items? wpf wpf

How can I make a column in a listbox in WPF the same width for all items?


You can use the IsSharedSizeScope attached property. In your template definition, attach a "shared size group" to each column, like this:

<Grid.ColumnDefinitions>    <ColumnDefinition SharedSizeGroup="col1" />    <ColumnDefinition SharedSizeGroup="col2" /></Grid.ColumnDefinitions>

... then define your ListBox as a shared size scope so it knows to size each "size group" the same way:

<ListBox Grid.IsSharedSizeScope="True">...</ListBox>