gpt4 book ai didi

.net - 包装 ItemsControls 的内容

转载 作者:行者123 更新时间:2023-12-05 06:46:41 29 4
gpt4 key购买 nike

我正在使用两个不同的 ItemsControl 来生成一个按钮列表。

<WrapPanel Orientation="Horizontal">
<ItemsControl ItemsSource="{Binding Commands}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Command="{Binding}">
<!-- ... -->
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

<ItemsControl ItemsSource="{Binding CurrentTransaction.Modifiers}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<ToggleButton IsChecked="{Binding IsEnabled}">
<!-- ... -->
</ToggleButton>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</WrapPanel>

第二个 ItemsControl 的按钮出现在新的“行”上

enter image description here

是否有可能第二个 ItemsControl 的按钮直接出现在第一个 ItemsControl 的按钮之后?按钮的数量可能会有所不同。它应该看起来像这样:

enter image description here

最佳答案

您可以将两个项目集合合并为一个,并且只有一个带有 ItemTemplateSelector 的 ItemsControl。为每个项目返回适当的 DataTemplate。

关于.net - 包装 ItemsControls 的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13992633/

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