[英]how to move from one page to another from button click in Xamarin.forms
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).. 我只是想知道如何从一个内容页面移动到另一个内容页面。请查看elseif()代码。我必须在该块中编写,以便我可以移动到另一个内容页面(命名为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
. 首先将您的主要
contentPage
包装在NavigationPage
。 From there you will use Navigation by PushAsync(new SomeNewPage());
从那里你将使用
PushAsync(new SomeNewPage());
导航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)... 示例示例 (取自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 } }; } } }
else if (username.Text == "kanak" && password.Text == "1234")
{
Navigation.PushAsync(new <App-Root-name>.<folder-name>.<Class-Name>());
}
In the code . 在代码中。 What is meant by
<App-Root-name>
and <folder-name>
and <Class-Name>
??? <App-Root-name>
和<folder-name>
以及<Class-Name>
是什么意思?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.