列表框项目方向为水平 [英] listbox items orientation to horizontal

查看:17
本文介绍了列表框项目方向为水平的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在列表框的默认样式中使列表框项目方向为水平.我的默认意思是我们使用混合获得的样式.

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.

推荐答案

使用 ItemsPanel 属性用水平 StackPanel 替换面板:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆