【发布时间】:2011-04-03 16:38:48
【问题描述】:
如何在列表框的默认样式中使列表框项目方向为水平。 我的意思是默认情况下我们使用混合获得的样式。
【问题讨论】:
标签: c# silverlight silverlight-4.0
如何在列表框的默认样式中使列表框项目方向为水平。 我的意思是默认情况下我们使用混合获得的样式。
【问题讨论】:
标签: c# silverlight silverlight-4.0
使用ItemsPanel 属性将面板替换为水平 StackPanel:
<ListBox>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
如果您想在样式中执行此操作,只需添加一个设置 ItemsPanel 属性的 Setter:
<Style TargetType="ListBox">
<!-- Rest of the style -->
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Style>
【讨论】: