Desmond
Desmond

Reputation: 117

How to make FlipView scrolling only one direction

A simple xaml like this

<FlipView>
    <FlipView>
        <FlipView.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Vertical" />
            </ItemsPanelTemplate>
        </FlipView.ItemsPanel>
        <Rectangle Fill="CornflowerBlue" />
        <Rectangle Fill="CornflowerBlue" />
    </FlipView>
    <FlipView>
        <FlipView.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Vertical" />
            </ItemsPanelTemplate>
        </FlipView.ItemsPanel>
        <Rectangle Fill="CornflowerBlue" />
        <Rectangle Fill="CornflowerBlue" />
    </FlipView>
    <ListBox>
        <Rectangle Fill="CornflowerBlue" />
        <Rectangle Fill="CornflowerBlue" />
    </ListBox>
</FlipView>

If the main FlipView's current item is a flipview,you can drag and scroll its item on two directions.But if it is a listbox,only one direction is available.means before your finger up,you cannot drag and scroll it on the other direction(Horizental or Vertical).

so how to make flipview's behavier as the same as listbox?

Upvotes: 1

Views: 1536

Answers (1)

Filip Skakun
Filip Skakun

Reputation: 31724

If you extract the default template from the FlipView you can see how the style has these setters:

<Setter
    Property="ScrollViewer.IsHorizontalRailEnabled"
    Value="False" />
<Setter
    Property="ScrollViewer.IsVerticalRailEnabled"
    Value="False" />
<Setter

From that you can deduce that setting ScrollViewer.IsHorizontalRailEnabled and ScrollViewer.IsVerticalRailEnabled on your FlipView to True gives you want you ask for.

Upvotes: 2

Related Questions