我想让
您将在
默认的
更新: 以下是使其工作的代码:
ListBox
的功能像一个 Grid
。每次添加新项时,它应该看起来像添加了一个新的 GridRow
(高度为 star)。因此,如果有两个项目,它们将各自占用可用空间的一半。在某些时候,Grid
行将小于项目的 MinHeight
,此时 Grid
将扩展,包含的 ScrollViewer
可以启动。您将在
ScrollViewer
中看到这种行为,其中包含一个 Grid
。但是,我需要让这个工作与 ListBox
一起,这样我就可以设置 ItemsSource
,创建一个 DataTemplate
并继续进行。默认的
ListBox
ItemsPanel
的问题在于它不会让我的第一个项目扩展以填充所有可用空间。更新: 以下是使其工作的代码:
<ListBox VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" Width="Auto" Height="Auto">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="1"></UniformGrid>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>