Articles in this section
Category / Section

How to disable the swipe gesture in SfNavigationDrawer

1 min read

Syncfusion NavigationDrawer in Xamarin provides SwipeGesture to make the drawer gets open when we swipe on the screen. When the SwipeGesture is disabled the user can use the ToggledDrawer method to open the NavigationDrawer.

 

To disable Swipe Gesture in NavigationDrawer follow the given procedures below.

 

Step 1: Create a sample of SNavigationDrawer and set EnableSwipeGesture to false so that it disables SwipeDesture.

 

The below code illustrates the way to achieve this.

XAML Code:

<navigation:SfNavigationDrawer x:Name="navigationDrawer"  EnableSwipeGesture="false" Position="Left" Transition="Push" TouchThreshold="30" DrawerHeight="100" DrawerWidth="120" DrawerHeaderHeight="100" DrawerFooterHeight="100"><!--    Set EnableSwipeGesture="True" to enable swipe gesture    --><navigation:SfNavigationDrawer.ContentView>  <StackLayout x:Name="ContentFrame" Orientation="Vertical">      <Button Text="Show Menu" Grid.Row="1"  BackgroundColor="#1aa1d6"  x:Name="Btnmenu" HorizontalOptions="Center" VerticalOptions="Center" ></Button>  </StackLayout></navigation:SfNavigationDrawer.ContentView><navigation:SfNavigationDrawer.DrawerHeaderView>  <Grid x:Name="headerLayout" BackgroundColor="#1aa1d6" >      <Label x:Name="header"  Text="Header View" FontSize="14" TextColor="White"  VerticalTextAlignment="Center" HorizontalTextAlignment="Center"  />  </Grid></navigation:SfNavigationDrawer.DrawerHeaderView><navigation:SfNavigationDrawer.DrawerFooterView>  <Grid x:Name="footerLayout" BackgroundColor="#1aa1d6" >      <Label x:Name="footer"  Text="Footer View" FontSize="14" TextColor="White"  VerticalTextAlignment="Center" HorizontalTextAlignment="Center"  />  </Grid></navigation:SfNavigationDrawer.DrawerFooterView>        <navigation:SfNavigationDrawer.DrawerContentView>  <Grid x:Name="drawerContent"  >      <Label x:Name="content"  Text="Drawer Content View" FontSize="14" TextColor="Black"  VerticalTextAlignment="Center" HorizontalTextAlignment="Center"  />  </Grid></navigation:SfNavigationDrawer.DrawerContentView></navigation:SfNavigationDrawer>  
 

 

C# Code:

namespace DrawerExample{    public partial class MainPage : ContentPage    {        public MainPage()        {            InitializeComponent();            Btnmenu.Clicked += (object sender, System.EventArgs e) =>            {                navigationDrawer.ToggleDrawer();            };        }    }} 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied