列表框项目的水平方向 [英] listbox items orientation to horizontal
本文介绍了列表框项目的水平方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在列表框的默认样式中使列表框项目朝向水平方向.我的意思是默认情况下是我们使用blend的样式.
How to make the listbox items orientation to horizontal in the default styling of a listbox. What i mean by default is the style which we get using blend.
推荐答案
Use the ItemsPanel property to replace the panel with a horizontal StackPanel:
<ListBox>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
如果要在样式中执行此操作,只需添加用于设置ItemsPanel属性的Setter:
If you want to do this in a Style, just add a Setter that sets the ItemsPanel property:
<Style TargetType="ListBox">
<!-- Rest of the style -->
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Style>
这篇关于列表框项目的水平方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文