user8428004
user8428004

Reputation:

Button make my app crashes?

i'am trying to make a button that's make me go to another page. but every time i pess the button my app crashes D: looking for help!

My Code.

Page 1 named "LoginPage"

public LoginPage()
{
    InitializeComponent();
    MainPage = new NavigationPage(new Signup());
}

async void SignupProcedure(object sender, EventArgs e)
{
    await Navigation.PushAsync(new Signup());
}

<Button x:Name="Btn_Signup" Text="Sign up" Clicked="SignupProcedure"/>

Page 2 Named "Signup"

async void OnPreviousPageButtonClicked(object sender, EventArgs e)
{
   await Navigation.PushAsync(new LoginPage());
}

Upvotes: 0

Views: 240

Answers (1)

Megadec
Megadec

Reputation: 466

Ensure your MainPage is declared in App.xaml.cs and not the constructor of your LoginPage like in your example.

Like the following:

public App()
    {

        InitializeComponent();

        MainPage = new NavigationPage(new Signup());

    }

Upvotes: 1

Related Questions