Karalix
Karalix

Reputation: 141

UWP IsVerticalRailEnabled not working

I have a Scrollviewer wrapping a ListView of movie posters, and it is scrollable verticaly and horizontaly and also zoomable.

When I set IsHorizontalRailEnabled="False" to the Scrollviewer the horizontal rails are effectively disabled, but whatever the value I assign to IsVerticalRailEnabled, the rails are never disabled.

<ScrollViewer ZoomMode="Enabled"
              MinZoomFactor="0.1"
              MaxZoomFactor="1"
              VerticalScrollBarVisibility="Auto"
              HorizontalScrollBarVisibility="Auto"
              IsVerticalRailEnabled="False"
              IsHorizontalRailEnabled="False">
    <ListView   Grid.Row="0"
                            Name="MovieListView"
                            ItemTemplate="{StaticResource ItemTemplate}"
                            ItemsSource="{Binding movie_posters_list}">
        <ListView.ItemsPanel>
            <ItemsPanelTemplate>
                <ItemsWrapGrid MaximumRowsOrColumns="15" Orientation="Horizontal" />
            </ItemsPanelTemplate>
        </ListView.ItemsPanel>
    </ListView>
</ScrollViewer>

I cant find any helpful documentation about this weird behaviour, any idea how to correct it ?

Upvotes: 2

Views: 254

Answers (1)

Karalix
Karalix

Reputation: 141

EDIT : As Justin XL mentionned in the comments, this way is breaking the UI virtualization of the ListView, and therefore should be avoided. See his comment for more info

I found the answer myself. I do not fully understand why I had to do that for it to work but OK. If you have an explanation on why I had to duplicate the property usage I would appreciate it :)

All I had to do is add ScrollViewer.IsVerticalRailEnabled="False" to my ListView element.

Note that I have to keep IsVerticalRailEnabled="False" in my ScrollViewer too for it to work.

Here is the updated xaml :

<ScrollViewer ZoomMode="Enabled"
              MinZoomFactor="0.1"
              MaxZoomFactor="1"
              VerticalScrollBarVisibility="Auto"
              HorizontalScrollBarVisibility="Auto"
              IsVerticalRailEnabled="False"
              IsHorizontalRailEnabled="False">
    <ListView   Name="MovieListView"
                ItemTemplate="{StaticResource ItemTemplate}"
                ItemsSource="{Binding movie_posters_list}"
                ScrollViewer.IsVerticalRailEnabled="False">
        <ListView.ItemsPanel>
            <ItemsPanelTemplate>
                <ItemsWrapGrid MaximumRowsOrColumns="15" Orientation="Horizontal" />
            </ItemsPanelTemplate>
        </ListView.ItemsPanel>
    </ListView>
</ScrollViewer>

Upvotes: 1

Related Questions