0

I am navigating from a master detail page (which has a side menu) to a normal page that has one back button in the header but nothing else like so:

        btn_anzeigeerstellen_pickcate.Clicked += delegate
        {
            Navigation.PushAsync(new Screen_SwipeView());
        };

I used the empty pages before, and they always had one back button. But now, since I am moving away from the master detail page, the result is this:enter image description here

While the lower backbutton just navigates back, the upper back button navigates to the very beginning of the app again (which is pointless) So the upper back button needs to be removed.

Also, I noticed that by swiping from left screen end to right, it will bring up the menu as from the master detail page, which is not bad, but it shows that the app still "thinks" it is inside the master detail page.

How can I alter that behavior?

Thank you!

Master Detail Page:

public partial class Screen_MainMenu : MasterDetailPage
    {
        public Screen_MainMenu()
        {
            InitializeComponent();
            //MasterPage.ListView.ItemSelected += ListView_ItemSelected;
        }

        private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            var item = e.SelectedItem as Screen_MainMenuMasterMenuItem;
            if (item == null)
                return;

            var page = (Page)Activator.CreateInstance(item.TargetType);
            page.Title = item.Title;

            Detail = new NavigationPage(page);
            IsPresented = false;

            MasterPage.ListView.SelectedItem = null;
        }
    }


 public partial class Screen_MainMenuMaster : ContentPage
    {
        public ListView ListView;

        public Screen_MainMenuMaster()
        {
            InitializeComponent();

            BindingContext = new Screen_MainMenuMasterViewModel();
            ListView = MenuItemsListView;
        }

        class Screen_MainMenuMasterViewModel : INotifyPropertyChanged
        {
            public ObservableCollection<Screen_MainMenuMasterMenuItem> MenuItems { get; set; }

            public Screen_MainMenuMasterViewModel()
            {
                MenuItems = new ObservableCollection<Screen_MainMenuMasterMenuItem>(new[]
                {
                    new Screen_MainMenuMasterMenuItem { Id = 0, Title = "Mein Profil" },
                    new Screen_MainMenuMasterMenuItem { Id = 1, Title = "Meine Anzeigen" },
                    new Screen_MainMenuMasterMenuItem { Id = 2, Title = "Merkliste" },
                    new Screen_MainMenuMasterMenuItem { Id = 3, Title = "Website" },
                    new Screen_MainMenuMasterMenuItem { Id = 4, Title = "Kontakt" },
                    new Screen_MainMenuMasterMenuItem { Id = 1, Title = "Hilfe" },
                    new Screen_MainMenuMasterMenuItem { Id = 2, Title = "Einstellungen" },
                    new Screen_MainMenuMasterMenuItem { Id = 3, Title = "Missbrauch melden" },
                    new Screen_MainMenuMasterMenuItem { Id = 4, Title = "Log Out" },

                });
            }

            #region INotifyPropertyChanged Implementation
            public event PropertyChangedEventHandler PropertyChanged;
            void OnPropertyChanged([CallerMemberName] string propertyName = "")
            {
                if (PropertyChanged == null)
                    return;

                PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
            }
            #endregion
        }
innomotion media
  • 862
  • 11
  • 30

1 Answers1

1

Well from the code that I can see and the code that I assume you have done I think that you are adding the MasterDetailPage itself into NavigationPage, in turn, causing the double nav bars when the detail page is in a navigation page.

Your master-detail page navigation should look something like this:

App.Xaml.cs

MainPage= new Screen_MainMenu();

Where i assume you have something like:

MainPage= new NavigationPage(new Screen_MainMenu());

Goodluck

Feel free to get back if you have questions.

FreakyAli
  • 13,349
  • 3
  • 23
  • 63
  • Heya, so i tried launching a page like this await Navigation.PushAsync(new NavigationPage(new Screen_SwipeView())); this resulted in another page opening that now had 3 headers (2 before) and another one added. So this is kinda where this needs fixing,but i need to make sure it actually leaves master detail page and renders a new navigation page and CLOSES the master detail page that it is surrounding... – innomotion media Apr 21 '20 at 13:02
  • Also, when I did it like this: Application.Current.MainPage = new NavigationPage(new Screen_SwipeView()); then there is only one bar on the next screen BUT also no more backbutton... ^^ – innomotion media Apr 21 '20 at 13:10
  • I think you are not using the `MasterDetailPage` correctly which is actually causing these issues can you try checking this https://stackoverflow.com/questions/49169049/hamburger-menu-xamarin-forms-masterdetailpage and recreating your `MaterDetailPage`? – FreakyAli Apr 22 '20 at 07:10