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

When select item then for the second time pick other one first to go back to page

I am using NavigationDrawer to go to Page1

That is working when i select Profile it is going to Page1, when i go back to mainpage en select Profile again nothing is happening because it is already selected.

Have to select another item en then select Profile again then i am going to Page1 .

What do i at or change when go back from Page1 to menu no item is selected ?

namespace GettingStarted
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
            hamburgerButton.Image = (FileImageSource)ImageSource.FromFile("hamburgericon.png");
            List<string> list = new List<string>();
            list.Add("Home");
            list.Add("Profile");
            list.Add("Inbox");
            list.Add("Outbox");
            list.Add("Sent");
            list.Add("Draft");
            listView.ItemsSource = list;
        }

        void hamburgerButton_Clicked(object sender, EventArgs e)
        {
            navigationDrawer.ToggleDrawer();
        }
        private void listView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            
            if (e.SelectedItem.ToString() == "Profile")
            {
                Navigation.PushAsync(new Page1());
         
                headerLabel.Text = "Menu";
            }
            navigationDrawer.ToggleDrawer();
        }
    }
}


3 Replies

KG Kanimozhi Gunasekaran Syncfusion Team October 22, 2019 09:03 AM UTC

Hi Boris Oprit,

Greetings from Syncfusion.

We have checked your requirement “While navigating back to the page, the SelectedItem does not get deselected in ListView” from our side. We have achieved your requirement by setting selected item as null. So, when back to the main page the selected item gets deselected. Please have the sample from the below link,

Please try the attached below sample and let us know if you have any concern on this.


Code Snippet: 
private void listView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
            if (e.SelectedItem != null && e.SelectedItem.ToString() == "Profile")
            {
                Navigation.PushAsync(new Page1());
                headerLabel.Text = "Menu";
                navigationDrawer.ToggleDrawer();
                ((ListView)sender).SelectedItem = null;
            }
           navigationDrawer.ToggleDrawer();         
  
 
Sample Link: 
Regards,
Kanimozhi G.
 



BO Boris Oprit October 22, 2019 08:43 PM UTC

Thanks ,

Works great .


RA Rachel A Syncfusion Team October 23, 2019 05:05 AM UTC

Hi Boris, 
 
Thanks for the confirmation. 
 
Please let us know if you need any further assistance. 
 
Thanks, 
Rachel. 


Loader.
Live Chat Icon For mobile
Up arrow icon