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

Published on April 26, 2015 by abundantcode

Filed under XAML

Last modified April 26, 2015

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 5 (1 votes)

This article have been viewed 6232 times

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>

Leave a Comment


x

You might be Interested in these Posts

C Program to find the G.C.D of a number using Recursive function

Problem Write a program in C to find the find the G.C.D of a number using recursion and display the ...

C Program to print a Half Pyramid using *

Problem Write a program in C to print Half pyramid using * as shown. * * * * * * * * * * ...

C Program to display Positive factors of a number

Problem Write a program in C to display all the positive factors of a number enter by the user. Ho...