gpt4 book ai didi

wpf - 可以使用带有数据模板的包装面板来水平对齐列表框中的项目

转载 作者:行者123 更新时间:2023-12-03 06:04:08 28 4
gpt4 key购买 nike

我正在尝试水平对齐列表框中的项目(项目是复选框项目)。如何将包裹面板与数据模板一起使用?

<ListBox  Name="Horizontal"  ItemsSource="{Binding Solution}" scrollViewer.HorizontalScrollBarVisibility="Disabled" >
<ListBox.ItemTemplate >
<DataTemplate >
<CheckBox Content="{Binding Name}" IsChecked="{Binding IsChecked}" Margin="5 5 0 0"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

最佳答案

我认为您需要 ItemsPanel 属性:

<ListBox Name="Horizontal" ItemsSource="{Binding Solution}" scrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<CheckBox Content="{Binding Name}" IsChecked="{Binding IsChecked}" Margin="5 5 0 0"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

关于wpf - 可以使用带有数据模板的包装面板来水平对齐列表框中的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17979106/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com