简体   繁体   中英

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 ?

在我的头顶,将Listbox的Horizo​​ntalContentAlignment属性设置为Stretch。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM