如何使隐式 ScrollViewer 出现在左侧而不是右侧 [英] How to make the implicit ScrollViewer appear on the left hand side instead of right hand side

查看:32
本文介绍了如何使隐式 ScrollViewer 出现在左侧而不是右侧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 ScrollViewer,当列表中有足够多的对象时,它会出现在右侧.我怎样才能让它出现在左侧?

I have a ScrollViewer which appears on the right hand side when enough objects are in the list. How can I make it appear on the left hand side?

<ListBox
    x:Name="MessageListBox" 
    BorderThickness="0" 
    ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
    HorizontalContentAlignment="Stretch"  
    AlternationCount="2" 
    ItemContainerStyle="{StaticResource AltStyle}" 
    SelectionMode="Extended">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <!-- button -->
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

推荐答案

可以通过将列表包装到 ScrollViewer 并更改 ScrollViewer 属性 FlowDirection 来实现RightToLeft.另外不要忘记将列表 FlowDirection 恢复到 LeftToRight 否则它将继承父级的方向.

It can be achieved by wrapping the list into ScrollViewer and changing the ScrollViewer property FlowDirection to RightToLeft. Also don't forget to restore the lists FlowDirection to LeftToRight otherwise it will inherit the parent's direction.

<ScrollViewer FlowDirection="RightToLeft"
    CanContentScroll="False" VerticalScrollBarVisibility="Auto">
  <ListBox ItemsSource="{Binding CustomItems}" FlowDirection="LeftToRight"/>
</ScrollViewer>

我是在 MSDN 社交博客上找到的,如何在左侧设置垂直滚动条

I found it on MSDN social blogs, How to Set VerticalScroll bar on Left side

这篇关于如何使隐式 ScrollViewer 出现在左侧而不是右侧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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