Reputation: 16900
One of the problems i am facing is listbox only takes so much as is needed to display it's items. How can i make listbox to occupy the full space that is available to itself?
Example:- If i place the listbox inside the grid it should occupy the full grid.
The current problem is if i give stretch to listbox and set it's height and width to Auto it will still only occupy the space it needs for displaying its items.
Thanks in advance :)
Upvotes: 1
Views: 127
Reputation: 189457
The ListBox itself will stretch to fill a * sized cell in a Grid. The problem is that the content of the ListBox doesn't do this.
You can do something about this for the width of the content items in a vertically oriented ListBox:-
<ListBox.ItemContainerStyle>
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</ListBox.ItemContentStyle>
This will cause the items (if their template allows) to stretch the width of the ListBox.
However for Horizontally oriented ListBox it would be tricker to get content to stretch to the height of the ListBox since the default ListBoxItem
template does not bind the VerticalContentAlignment
property.
Upvotes: 1