How to stretch ListBox Items horizontally to full width of the ListBox in Xaml ?

If you want the list items to horizontally stretch to full width of the ListBox in Xaml , you can set the HorizontalContentAlignment property to the value as shown below.

How to stretch ListBox Items horizontally to full width of the ListBox in Xaml ?

Below is a sample code snippet demonstrating the usage of the ItemContainerStyle of the Listbox to set the Style.

<ListBox x:Name="lstACNames">
        <ListBox.ItemContainerStyle>
            <Style TargetType="ListBoxItem">
                <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
            </Style>
        </ListBox.ItemContainerStyle>
</ListBox>
Tags :

Leave Your Comment

Liked this content?. Please spread the word :)