How to close the NavigationDrawer when user tapped back button, and don't close main page

Dear,


I've a main page with navigation drawer, every thing is going well, but when I tapped on back button on my mobile to close the navigation drawer, the main page also closed. 

Is there is any property to close the navigation drawer only and remain in current page ?

I'm using Syncfusion.Xamarin.SfNavigationDrawer(v19.3.0.55)


Regards


4 Replies 1 reply marked as answer

SS Suganya Sethuraman Syncfusion Team December 9, 2021 09:52 AM UTC

Hi Ahmed,

Greetings from Syncfusion.

We have analyzed your query. We have prepared a sample using SfNavigationDrawer based on your requirement as below code snippet,

Code snippet
 
        protected override bool OnBackButtonPressed() 
        { 
            navigationDrawer.IsOpen = false; 
            return true; 
        } 

Please have a sample for your reference,

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/NavigationDrawer_BackButton1450963918

Please check if the sample satisfies your requirement and let us know if you have any concerns.

Regards,
Suganya Sethuraman.
 
 



AA Ahmed Aglan December 9, 2021 12:52 PM UTC

Hi  Suganya Sethuraman,


Thank you for your replay, it helps me to fix issue, 

next is more enhanced code:


    protected override bool OnBackButtonPressed()

    {
      // true or false to disable or enable the action
      if (navigationDrawer.IsOpen)
      {
        navigationDrawer.ToggleDrawer();
        return true;
      }
      return base.OnBackButtonPressed();
    }

Marked as answer

NK Nguyen Khoa Lu December 10, 2021 03:08 AM UTC

It will not working on iOS platform.



SS Suganya Sethuraman Syncfusion Team December 10, 2021 01:09 PM UTC

Hi Nguyen,

We have analyzed your query. Could you please provide more information, such as whether you mentioned the NavigationPage back button? This will help us to investigate further and provide better solution at earliest.

Regards,
Suganya Sethuraman.
 


Loader.
Up arrow icon