I am trying to make my listbox to have the same width as the window here is a minimum example.
<ListBox ItemsSource="{Binding MyList}" Background="Blue">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Background="Black" HorizontalAlignment="Stretch">
<TextBlock Text="test" HorizontalAlignment="Stretch"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
The result looks like
Where the blue part is the list box and the black parts are the rows. I am trying to make the rows to have the same width as the listbox