我想使添加的图像在水平方向上对齐,但是我尝试使所有内容保持在垂直方向上对齐
所以我的物品像这样对齐->
但是我想要这样的东西->
这是我尝试的->
<ListBox x:Name="listbox" ScrollViewer.VerticalScrollBarVisibility="Visible" Grid.Row="1">
<ItemsPanelTemplate>
<StackPanel HorizontalAlignment="Stretch">
<StackPanel.Resources>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
</StackPanel.Resources>
</StackPanel>
</ItemsPanelTemplate>
<ListBox.ItemTemplate >
<DataTemplate >
<WrapPanel Orientation="Horizontal" >
<Image Height="100" Width="100" Stretch="Fill" Source="{Binding ConvertedData}" />
</WrapPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
使用ItemsPanelTemplate中的WrapPanel。 ItemsPanel是可用于ItemsControl内部项目布局的对象。 ItemTemplate中的面板控制单个项目的布局。