我有一个ItemsItemsControl。我希望像图片一样订购商品。如果有更多元素(该空间),则应该有一个水平滚动条。我该如何存档?
相关代码:
<ItemsControl.Template>
<ControlTemplate TargetType="ItemsControl">
<ScrollViewer PanningMode="Both" >
<ItemsPresenter />
</ScrollViewer>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
编辑:很抱歉,报告建议的解决方案不起作用,事实证明项目的高度在运行时动态变化,导致垂直仅留出一个项目的空间。
这样的事情会工作吗?
<ItemsControl.Template>
<ControlTemplate TargetType="ItemsControl">
<ScrollViewer HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Disabled" >
如果这不起作用,请尝试此
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Height="{Binding RelativeSource={RelativeSource
Mode=FindAncestor, AncestorType={x:Type ScrollViewer}},
Path=ActualHeight}" />
编辑
别忘了制作您的WrapPanel Orientation="Vertical"
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句