akshay2000
akshay2000

Reputation: 824

Disable diagonal panning in nested FlipView

My XAML roughly looks as follows.

<FlipView>
    <FlipViewItem>
        <Grid Height="400" Background="Blue"/>
    </FlipViewItem>
    <FlipViewItem>
        <Grid>
            <FlipView x:Name="DigestFlipView" Style="{StaticResource DigestViewStyle}"/>
        </Grid>
    </FlipViewItem>
</FlipView>

And then in my DigestViewStype I have made it vertical as follows:

<Setter Property="ItemsPanel">
    <Setter.Value>
        <ItemsPanelTemplate>
            <ItemsStackPanel Orientation="Vertical"/>
        </ItemsPanelTemplate>
    </Setter.Value>
</Setter>

What I want is, when swipe is vertical, only inner FlipView should kick in. Also, when swipe is horizontal, only outer FlipView should kick in.

I get the desired behavior if I replace inner FlipView with a ListView. ListView scrolls for vertical swipes and FlipView for horizontal ones. I have tried playing with templates with no luck. Is there a way to achieve what I need with FlipViews?

Upvotes: 0

Views: 105

Answers (1)

Jerry Nixon
Jerry Nixon

Reputation: 31841

A ScrollViewer can scroll horizontally. A ScrollViewer can scroll vertically. And, a ScrollViewer can scroll both horizontally and vertically - you are calling this third case "diagonal" scrolling.

A ScrollViewer has a feature where once it starts scrolling either horizontally or vertically, it will no longer scroll the opposite. It sounds like this is what you want. This feature is called "rails".

https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.scrollviewer.ishorizontalrailenabled.aspx

https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.scrollviewer.isverticalrailenabled.aspx

Upvotes: 1

Related Questions