Esteban Chornet
Esteban Chornet

Reputation: 1227

Is there a way to disable Xamarin Forms SwipeGestureRecognizer on Desktop?

I have a Xamarin Forms app and I wonder if it's possible to allow SwipeGestureRecognizer only for Phones (or small screens).

I'm using a view with 2 content views. On Desktop I want to see both at screen, but on Phone I want to see them individually (swipe gesture).

        <ContentView.GestureRecognizers>
            <SwipeGestureRecognizer Command="{Binding SwipedViewCommand}" Direction="Right" />
        </ContentView.GestureRecognizers>

The command inverts the value of a boolean, and each content view is visible binded to that boolean (one checking for true, the other one to false)

https://learn.microsoft.com/es-es/xamarin/xamarin-forms/app-fundamentals/gestures/swipe

Upvotes: 1

Views: 463

Answers (1)

YZahringer
YZahringer

Reputation: 128

There is an issue on XF: https://github.com/xamarin/Xamarin.Forms/issues/8756

In the meantime, you can set CanExecute of Command:

new Command(() => { }, () => Device.Idiom == TargetIdiom.Phone);

Upvotes: 1

Related Questions