1

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!

Sebastian Budka
  • 396
  • 1
  • 8
  • 19
  • 2
    in `ItemContainerStyle` set `HorizontalContentAlignment` instead of `HorizontalAlignment` – dkozl Mar 23 '15 at 14:30
  • 1
    Thank you very much, `HorizontalContentAlignment` did the trick. All answers I found earlier was about `HorizontalAlignment` – Sebastian Budka Mar 30 '15 at 08:24

0 Answers0