该列表包含带有标题的缩略图。标题应与底部对齐,缩略图应与其容器的顶部边缘对齐。为此,您需要以某种方式计算并设置每个元素的容器高度:
一个容器用于 list WrapPanel,带有元素的整个面板可以延伸GridSplitter,这导致元素跳转到下一行/上一行。因此,行中的元素数量可能会发生变化,您需要每次调整它们的高度。
标记:
<ListBox Grid.Row="1"
Padding="15"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ItemsSource="{Binding Previews}"
SelectionMode="Extended">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" Orientation="Horizontal"></WrapPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Background="Aqua">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="25" />
</Grid.RowDefinitions>
<Image Grid.Row="0"
MaxHeight="80"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Stretch="Uniform"
Source="{Binding Path}" />
<Label Grid.Row="1" Content="{Binding Name}" HorizontalAlignment="Center" VerticalAlignment="Bottom" MaxWidth="90px" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
告诉我怎么做?


