locked
Equal Column Width RRS feed

Answers

  • I don't have a chance to test this right now, but I think the responders in that thread missed the real issue, which is that HorizontalContentAlignment in a ListBox defaults to Auto. It needs be the Stretch so that a ListBoxItem expands to the full width of the ListBox. Try adding this ListBox.ItemContainerStyle to your ListBox definition:

    <ListBox>
        <ListBox.ItemContainerStyle>
            <Style TargetType="ListBoxItem">
                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            </Style>
        </ListBox.ItemContainerStyle>

    </ListBox>



    Richad Woo
    Thursday, June 16, 2011 5:59 PM

All replies

  • I don't have a chance to test this right now, but I think the responders in that thread missed the real issue, which is that HorizontalContentAlignment in a ListBox defaults to Auto. It needs be the Stretch so that a ListBoxItem expands to the full width of the ListBox. Try adding this ListBox.ItemContainerStyle to your ListBox definition:

    <ListBox>
        <ListBox.ItemContainerStyle>
            <Style TargetType="ListBoxItem">
                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            </Style>
        </ListBox.ItemContainerStyle>

    </ListBox>



    Richad Woo
    Thursday, June 16, 2011 5:59 PM
  • I verified it works. Set HorizontalContentAlignment with the xaml I posted.
    Thursday, June 16, 2011 8:01 PM