WPF ListBox ItemTemplate: how to make content fill free space?

I installed ListBox.ItemTemplatesomething like

<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>

Result

How can I make StackPanelfill the entire width ListBox?

+3
source share
1 answer

Outside the top of the head, set the HorizontalContentAlignment property in the list to stretch.

+5
source

Source: https://habr.com/ru/post/1776833/


All Articles