问题
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