public partial class App : Application {
public App() {
InitializeComponent();
// A) using the AppShell and the routes
// MainPage = new AppShell();
// B) using a custom LoginPage with the possibility to navigate
// MainPage = new NavigationPage(new LoginPage());
// using a custom LoginPage w/o navigation features
MainPage = new LoginPage();
}
}
public class LoginPage : ContentPage {
public LoginPage() {
var loginButton = new Button {Text = "Login"};
var signupButton = new Button {Text = "Signup"};
loginButton.Clicked+=LoginButtonOnClicked;
signupButton.Clicked+=SignupButtonOnClicked;
Content = new StackLayout {
Children = {
new Label {Text = "Please login."},
loginButton,
signupButton
}
};
}
private void LoginButtonOnClicked(object sender, EventArgs e) {
// simple replace the app mainpage
App.Current.MainPage = new AppShell();
}
private void SignupButtonOnClicked(object sender, EventArgs e) {
App.Current.MainPage = new NavigationPage(new SignupPage());
// or create a new SignupShell
// App.Current.MainPage = new SignupShell();
}
}