Contents
- Enabling Swipe Gesture
- Swipe Sensitivity
Having trouble getting help?
Contact Support
Contact Support
SwipeGesture and its Sensitivity in Xamarin Navigation Drawer
8 Aug 20224 minutes to read
NavigationDrawer supports swipe gesture for opening and closing the drawer.
Enabling Swipe Gesture
It can be enabled/disabled using EnableSwipeGesture
property.
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:NaviSample"
xmlns:navigationdrawer="clr-namespace:Syncfusion.SfNavigationDrawer.XForms;assembly=Syncfusion.SfNavigationDrawer.XForms"
x:Class="NaviSample.MainPage">
<navigationdrawer:SfNavigationDrawer x:Name="navigationDrawer"
EnableSwipeGesture="True">
<navigationdrawer:SfNavigationDrawer.DrawerHeaderView>
<Grid BackgroundColor="#1aa1d6"
VerticalOptions="Center"
HorizontalOptions="Center">
<Label Text="Header view"
FontSize="16"
VerticalOptions="Center"
HorizontalOptions="Center"/>
</Grid>
</navigationdrawer:SfNavigationDrawer.DrawerHeaderView>
</navigationdrawer:SfNavigationDrawer>
</ContentPage>
navigationDrawer.EnableSwipeGesture = true;
Swipe Sensitivity
In smaller screens user may find it difficult to swipe the drawer from the edge in such cases we can increase the swipe region using TouchThreshold
property. It can be set as below:
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:NaviSample"
xmlns:navigationdrawer="clr-namespace:Syncfusion.SfNavigationDrawer.XForms;assembly=Syncfusion.SfNavigationDrawer.XForms"
x:Class="NaviSample.MainPage">
<navigationdrawer:SfNavigationDrawer x:Name="navigationDrawer"
EnableSwipeGesture="True"
TouchThreshold="70">
<navigationdrawer:SfNavigationDrawer.DrawerHeaderView>
<Grid BackgroundColor="#1aa1d6"
VerticalOptions="Center"
HorizontalOptions="Center">
<Label Text="Header view"
FontSize="16"
VerticalOptions="Center"
HorizontalOptions="Center"/>
</Grid>
</navigationdrawer:SfNavigationDrawer.DrawerHeaderView>
</navigationdrawer:SfNavigationDrawer>
</ContentPage>
navigationDrawer.TouchThreshold = 70;