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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Resetting Navigation Drawer's selected item

Thread ID:

Created:

Updated:

Platform:

Replies:

150897 Jan 23,2020 03:17 PM UTC Jan 24,2020 01:45 PM UTC Xamarin.Forms 1
loading
Tags: SfNavigationDrawer
Gregory
Asked On January 24, 2020 12:07 PM UTC

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();
}
}
}


Anandraj Selvam [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon