2

As I am using xamarin.forms for my application in android which I have to navigate from one page to another. My question is, if navigating from one page to another page adds it to the navigation stack. For example, If my app has navigation such as Page1 --> Page2 --> Page3 --> Page4 --> Page1 (It behaves like cycle) will it replace Page1 when I navigate to that page on second time or will it be adding it to the stack. Can anyone explain about navigation in a simple way??

EDIT

What I mean by replace means if navigating from one page to another adds it to the stack, Won't it affect the performance of the application if the navigation continues like a loop and keeps on adding it to the stack??

Note: I don't want to go back to previous page, Just want to navigate from one to another continously.

Thanks in advance

Femil Shajin
  • 1,768
  • 6
  • 24
  • 38

3 Answers3

0

Can you try to elaborate on the question a bit more? What do you mean by 'replace'?

It's a stack, so no: the first page1 will not be 'replaced', rather a 'copy' will be in place.

Example:

Imagine a list view with bound data objects. When you click an item, you get to an item details page. Imagine the details page to have previous and next buttons to navigate to other items and you press one. The stack will look like this: ListViewPage -> ItemsPage -> ItemsPage.

thomiel
  • 2,467
  • 22
  • 37
0

What you're talking about is CarouselPage

CarouselPage takes several ContentPage children and allows you to swipe sideways to switch the page.

public class App
{
    public static Page GetMainPage ()
    {  
        var carousel = new CarouselPage ();
        carousel.Children.Add (new ContentPage () {
            Title="One",
            Content = new BoxView {
                WidthRequest = 90,
                HeightRequest = 100,
                BackgroundColor = Color.Blue
            }
        });
        carousel.Children.Add (new ContentPage () {  
            Title="TWO",
            Content = new BoxView {
                WidthRequest = 90,
                HeightRequest = 100,
                BackgroundColor = Color.Red
            }
        }); 
        return carousel;
    }
}

Alternatively you can put two buttons (or suitable UI elements) on each page you want to show and use Navigation.PushModalAsync() to navigate to previous/next pages

Sten Petrov
  • 10,943
  • 1
  • 41
  • 61
0

Using this.Navigation.PopModalAsync () before PushModalAsync did the trick for me.

this.Navigation.PopModalAsync ();

Now my application runs smoothly :)

Femil Shajin
  • 1,768
  • 6
  • 24
  • 38