I don't know how to better name this problem, so let's describe it a little bit more specific. I have ListBox which contains grids with content:
<ListBox Grid.Column="2" Panel.ZIndex="2">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalAlignment" Value="Stretch" />
</Style>
</ListBox.ItemContainerStyle>
<Grid Height="30" Margin="5">
<StackPanel Orientation="Horizontal" Panel.ZIndex="2">
<!-- some more code -->
</StackPanel>
<ProgressBar Minimum="0" Maximum="{Binding TotalBytesToReceive}"
Value="{Binding BytesReceived}"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
</Grid>
</ListBox>
I want Grid to fit ListBox width, so the ProgressBar Stretch all over the space, and content of StackPanel to be in the middle (it is already done). I was trying to set following properties of grid width="auto", HorizontalAlignment="Stretch" but it also doesn't work.
I also found that setting proper Setter in ListBox.ItemContainerStyle (you can find it in posted code) should do the trick, but it still looks the same.
Thanks in advance!