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

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

Thread ID:

Created:

Updated:

Platform:

Replies:

148474 Oct 21,2019 06:05 PM UTC Oct 23,2019 05:05 AM UTC Xamarin.Forms 3
loading
Tags: SfNavigationDrawer
Boris Oprit
Asked On October 21, 2019 06:05 PM UTC

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


Kanimozhi Gunasekaran [Syncfusion]
Replied On 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.
 


Boris Oprit
Replied On October 22, 2019 08:43 PM UTC

Thanks ,

Works great .

Rachel A [Syncfusion]
Replied On 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. 


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