I just wanted to know that how to move from one Content Page to another Content Page..Please review the elseif() code ..What I have to write in that block so that I could move to another Content Page(named as MainView.cs)..
button.Clicked += (sender, e) =>
{
if (String.IsNullOrEmpty(username.Text) || String.IsNullOrEmpty(password.Text))
{
DisplayAlert("Oops!!Validation Error", "Username and Password are required", "Re-try");
}
else if (username.Text == "kanak" && password.Text == "1234")
{
// your code here
}
else
{
DisplayAlert("Failed", "Invalid User", "Login Again");
}
};
Any help is appreciated..
First wrap you main contentPage in a NavigationPage. From there you will use Navigation by PushAsync(new SomeNewPage());.
In your case it should be....
else if (username.Text == "kanak" && password.Text == "1234")
{
Navigation.PushAsync(new <App-Root-name>.<folder-name>.<Class-Name>());
}
Sample Example (Taken From GitHub)...
using System;
using Xamarin.Forms;
namespace FormsGallery
{
class TableViewMenuDemoPage : ContentPage
{
public TableViewMenuDemoPage()
{
Label header = new Label
{
Text = "TableView for a menu",
Font = Font.SystemFontOfSize(30, FontAttributes.Bold),
HorizontalOptions = LayoutOptions.Center
};
TableView tableView = new TableView
{
Intent = TableIntent.Menu,
Root = new TableRoot
{
new TableSection("Views for Presentation")
{
new TextCell
{
Text = "Label",
Command = new Command(async () =>
await Navigation.PushAsync(new LabelDemoPage()))
},
new TextCell
{
Text = "Image",
Command = new Command(async () =>
await Navigation.PushAsync(new ImageDemoPage()))
},
new TextCell
{
Text = "BoxView",
Command = new Command(async () =>
await Navigation.PushAsync(new BoxViewDemoPage()))
},
new TextCell
{
Text = "WebView",
Command = new Command(async () =>
await Navigation.PushAsync(new WebViewDemoPage()))
},
}
}
};
// Build the page.
this.Content = new StackLayout
{
Children =
{
header,
tableView
}
};
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With