Synchronize items Width in WrapPanel
if you want to have the same width size for each items in WrapPanel (in in ListBox for sample)
you can use Grid.IsSharedSizeScope= »True » like this
<Window.Resources>
<DataTemplate DataType="{x:Type local:ColorX}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"
SharedSizeGroup="ColumnSize" />
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal"
Margin="2">
<Rectangle Width="40"
Height="25"
Fill="{Binding Brush}"
Stroke="Black" />
<TextBox Text="{Binding Name}"
IsReadOnly="true"
Background="Transparent"
VerticalAlignment="Center"
BorderThickness="0"
Margin="4 0 4 0" />
</StackPanel>
</Grid>
</DataTemplate>
</Window.Resources>
<Grid>
<ListBox ItemsSource="{Binding .}"
Margin="10"
BorderThickness="1"
BorderBrush="RoyalBlue"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True"
Grid.IsSharedSizeScope="True" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</Grid>
