WPF ListBox ItemTemplate:如何使内容填充可用空间?

时间:2023-02-09 16:46:47

I have set my ListBox.ItemTemplate to something like below

我将ListBox.ItemTemplate设置为如下所示

<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

结果是

WPF ListBox ItemTemplate:如何使内容填充可用空间?

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

如何使StackPanel填充ListBox的整个宽度?

1 个解决方案

#1


5  

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

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

#1


5  

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

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