Search code examples
c#windows-store-appsuwpflipview

How to disable swipe navigation of flipview on touch in c# in windows store apps


I have developed an app in which I have more than one page in flipview. now I want to stop the swipe navigation on touch only. i have used Isenabled property but
This will disable the content of the flipview as well, I just wanted to disable its navigation but allow the user to interact with its content because I have need to drag and drop and also zoom-in and zoom-out with its content. please help me in solving the problem.


Solution

  • You can try this method by setting the ManipulationMode as TranslateX and put the code below inside your FlipView:

    xaml:

      <FlipView Width="300" Height="300" Name="MyFlipView">
            <FlipViewItem ManipulationMode="TranslateX" ManipulationDelta="FlipViewItem_ManipulationDelta">
                <Image Source="Assets/1.jpg" ></Image>
            </FlipViewItem>
            <FlipViewItem ManipulationMode="TranslateX" ManipulationDelta="FlipViewItem_ManipulationDelta">
                <Image Source="Assets/2.jpg" ></Image>
            </FlipViewItem>
        </FlipView>
    

    code behind:

            private void FlipViewItem_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
        {
            if (e.Delta.Translation.X != 0)
            {
                e.Handled = true;
            }
        }