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

Cannot Navigate between pages

$
0
0

Hi,

Am not sure what I am doing wrong. I tried to follow the introduction documentation for Xamarin.Forms but with no luck. I am not getting any errors, I just can't navigate to the next page.

MainActivity

var app = new App ();

LoadApplication (app);

var rootPage = new NavigationPage(app.MainPage);
App.Navigation = rootPage.Navigation;

App

public static INavigation Navigation { get; set; }

public App ()
{
// The root page of your application
MainPage = GetMainPage ();
}

public static Page GetMainPage()
{
var mainNav = new NavigationPage(new MainPage());
return mainNav;
}

MainPage

public class MainPage : ContentPage
{
public MainPage ()
{
var centralButton = new Button();
centralButton.Text = "ClickToNextPage";
centralButton.Clicked += (object sender, EventArgs e) => {
GoToNextPage();
};

        Content = new StackLayout {
            Spacing = 10,
            VerticalOptions = LayoutOptions.Center,
            Children = {
                new Label {
                    XAlign = TextAlignment.Center,
                    Text = "Page1"
                },
                centralButton
            }
        };
    }

}

private void GoToNextPage()
{
App.Navigation.PushAsync(new NextPage());
}

NextPage

public class NextPage : ContentPage
{
Label countdownLbl;

    public ShowCountdownForm ()
    {
        countdownLbl = new Label {
            XAlign = TextAlignment.Center,
            Text = "NextPageReached!"
        };

        // The root page of your application

        this.Content = new StackLayout {
            Spacing = 10,
            VerticalOptions = LayoutOptions.Center,
            Children = {
                countdownLbl
            }
        };
    }

}


Viewing all articles
Browse latest Browse all 58056

Trending Articles



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