如何使隐式 ScrollViewer 出现在左侧而不是右侧

2024-01-11

我有一个ScrollViewer当列表中有足够的对象时,它会出现在右侧。如何让它出现在左侧?

<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 to RightToLeft。另外不要忘记恢复列表FlowDirection to LeftToRight否则它将继承父级的方向。

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

我在 MSDN 社交博客上找到了它,如何设置左侧垂直滚动条 http://social.msdn.microsoft.com/Forums/vstudio/en-US/e796231d-5c92-44b4-bb7e-c3b74d81a99c/how-to-set-verticalscroll-bar-on-left-side?forum=wpf

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使隐式 ScrollViewer 出现在左侧而不是右侧 的相关文章

随机推荐