Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Back button not removing page from Navigation stack

$
0
0

I have a listview on a page with menu items. When I click a menu item, a new page is pushed and everything works great. I can use the back button to get back. However, if I click the same menu item again, it will go to the page and then instantly go forward to another instance of the same page, then I need to click back twice to get back to the original page. If I click the menu item again, then it will go forward 2 times and I need to click back 3 times, etc. I really don't know what is causing this. I have another page in my app where I call Navigation.PushAsync(page) and it works fine. I don't know if it is the way I am using the Activator.CreateInstance or some other reason.

Anyone have any thoughts of what might be causing this?

Thanks!!

        private void BindMenu()
        {
            var menuItems = new List<ListMenuItem>();
            menuItems.Add(new ListMenuItem { Title = "Orders", IconSource = "icon.png", TargetType = typeof(OrderListPage) });
            listViewMenu.ItemsSource = menuItems;
            listViewMenu.ItemSelected += listViewMenu_ItemSelected;
        }

        private async void listViewMenu_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            var item = e.SelectedItem as ListMenuItem;
            if (item != null)
            {
                Page page = (Page)Activator.CreateInstance(item.TargetType);
                await Navigation.PushAsync(page);
            }
        }

Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>