Home > database >  How do I implement Navigation that behaves like a circle?
How do I implement Navigation that behaves like a circle?

Time:10-24

I have got 4 pages. Now my app starts with page1.

The navigation should work like this: page1 > page2 > page3 > page4 and than page4 should open page1 again. And so on.

The pages don't need to remember the page that called await Navigation.PushModalAsync(NextPage) therefore I dont think hirachial navigation is the solution to the problem. I don't know what I have to work with... I thought about using the visabilties of the pages or using a CarouselPage... Maybe someone has an idea of how to implement this behaviour... Thanks alot guys!

CodePudding user response:

Maybe something like this if the navigation do not change .

In App.xaml.cs

MainPage = new NavigationPage(new page1());

Starts with page 1

Then in page 1 a button clicked

 private async void Button_Clicked(object sender, EventArgs e)
    {
   
            await Navigation.PushAsync(new page2());
    }

and in page2 button

 private async void Button_Clicked(object sender, EventArgs e)
    {
      
            await Navigation.PushAsync(new page3());
    }

Page 3 button

 private async void Button_Clicked(object sender, EventArgs e)
    {
      
            await Navigation.PushAsync(new page4());
    }

And then in page 4

 private async void Button_Clicked(object sender, EventArgs e)
    {
     
            await Navigation.PushAsync(new page1());
    }

If using this you might want to remove the backbutton

  • Related