gpt4 book ai didi

带有 DataTemplate 的 WPF WrapPanel/StackPanel?

转载 作者:行者123 更新时间:2023-12-04 14:35:38 30 4
gpt4 key购买 nike

我必须做什么才能在 WrapPanel 或 StackPanel 中使用 DataTemplate?

在 ListBox 上它如此简单,但我找不到在面板上执行此操作的方法...

编辑:我想要的是一个 ListBox,它可以像 WrapPanel 一样放置项目。

最佳答案

如果我理解正确,您可以使用容器的 ItemsPanel 属性。我使用类似的东西来使用水平 StackPanel 制作我的 ItemsControl 布局:

<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>

因此,更具体地针对您的情况:
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>

关于带有 DataTemplate 的 WPF WrapPanel/StackPanel?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/666637/

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