We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Resetting Navigation Drawer's selected item

Hi, 

I currently have a content page that uses the SfNavigationDrawer. When selecting the links on the control the app pushes to a navigation page:

This all works as should, the issue I am having is that when I go back to the previous page in the navigation hierarchy the Hamburger menu has the item highlighted representing the page I have just come back from and as such I am unable to navigate to that page a second time. Ideally, when navigating back to the page the hamburger menu should reset and have no items selected.

Does anyone know how  would achieve this?

Here is my xaml.cs:

namespace Tapiit.App.Views.Courses
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class CoursesPage : ContentPage
{
public CoursesPage()
InitializeComponent();

var settings = new ApplicationSettings();
menuName.Text = settings.Name;

hamburgerButton.ImageSource = (FileImageSource)ImageSource.FromFile("ic_hamburger.png");
var list = new List();
list.Add(HamburgerItems.MyAccount);
list.Add(HamburgerItems.Logout);
listView.ItemsSource = list;
}

void hamburgerButton_Clicked(object sender, EventArgs e)
{
navigationDrawer.ToggleDrawer();
}

private async void listView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
if (e.SelectedItem.ToString() == HamburgerItems.MyAccount)
{
await Navigation.PushAsync(new MyAccountDetailsPage());
}
else if (e.SelectedItem.ToString() == HamburgerItems.Logout)
{
    new ApplicationSettings()
{
AccessToken = string.Empty,
Email = string.Empty,
Password = string.Empty
};

Application.Current.MainPage = new NavigationPage(new LandingPage());
}
navigationDrawer.ToggleDrawer();
}
}
}


1 Reply

AS Anandraj Selvam Syncfusion Team January 24, 2020 01:45 PM UTC

Hi Gregory, 
  
Greetings from the Syncfusion. 
  
We would like to let you know that we have checked the reported query and we suggest you to make listView.SelectedItem to null while navigating the page. 
  
Please let us know if you have any other concerns. 
 
  
Regards, 
Anand Raj 


Loader.
Live Chat Icon For mobile
Up arrow icon