Jiew Meng
Jiew Meng

Reputation: 88197

WPF ListBox ItemTemplate: How to make contents fill available space?

I have set my ListBox.ItemTemplate to something like below

<ListBox.ItemTemplate>
    <DataTemplate>
        <StackPanel Margin="10">
            <TextBlock Text="{Binding Args}" />
            <ProgressBar Value="{Binding Progress}" Height="10" />
            <TextBlock Text="{Binding Status}" />
            <TextBlock Text="{Binding Result}" />
        </StackPanel>
    </DataTemplate>
</ListBox.ItemTemplate>

The result is

How can I make the StackPanel fill the entire width of the ListBox?

Upvotes: 3

Views: 6033

Answers (1)

Gishu
Gishu

Reputation: 136613

Off the top of my head, Set the HorizontalContentAlignment property of the Listbox to Stretch.

Upvotes: 5

Related Questions