ScrollViewer.IsHorizontalRailEnabled=“False” or ScrollViewer.IsHorizontalRailEnabled=“True” has no effect

放肆的年华 提交于 2019-12-11 19:34:19

问题


I am learning xaml and I am at Gridview. I have noticed that when I type in:

<GridView x:Name="Grid1" Grid.Row="1" SelectionMode="None"  Padding="120,0,0,0" RenderTransformOrigin="0.5,0.5" d:LayoutRounding="Auto"
              ScrollViewer.IsHorizontalRailEnabled="False">

or

<GridView x:Name="Grid1" Grid.Row="1" SelectionMode="None"  Padding="120,0,0,0" RenderTransformOrigin="0.5,0.5" d:LayoutRounding="Auto"
              ScrollViewer.IsHorizontalRailEnabled="True">

There is no difference when I run the app. I would like to know if "ScrollViewer.IsHorizontalRailEnabled" really does anything, or am I doing something wrong. Also same for "ScrollViewer.IsVerticalRailEnabled"

I have been to MSDN, the explanation there doesn't help. Thanks.


回答1:


To enable horizontal scroll, you need to do this

<GridView x:Name="Grid1" Grid.Row="1" SelectionMode="None"  Padding="120,0,0,0" RenderTransformOrigin="0.5,0.5" d:LayoutRounding="Auto">
<ScrollViewer HorizontalScrollBarVisibility="Auto" HorizontalScrollMode="Enabled">

<!-- Inside XAML code here -->

</ScrollViewer>
</GridView>

To enable vertical scroll, you need to do this

<GridView x:Name="Grid1" Grid.Row="1" SelectionMode="None"  Padding="120,0,0,0" RenderTransformOrigin="0.5,0.5" d:LayoutRounding="Auto">
<ScrollViewer VerticalScrollBarVisibility="Auto" VerticalScrollMode="Enabled">

<!-- Inside XAML code here -->

</ScrollViewer>
</GridView>

Hope this helps!



来源:https://stackoverflow.com/questions/31358080/scrollviewer-ishorizontalrailenabled-false-or-scrollviewer-ishorizontalrailena

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!