【发布时间】:2019-07-24 09:07:42
【问题描述】:
有人可以教我如何在内容页面之间导航吗?我一直在阅读许多教程,但我无法实现它。我有这个小代码,我想在按下按钮时在页面之间切换。我使用 MVVM 模型有我的 MainViewModel
public class MainViewModel
{
public Page1 PageNumberOne { get; set; }
public Page2 PageNumberTwo { get; set; }
public MainViewModel()
{
this.PageNumberOne = new Page1();
}
}
这是我的Page1视图模型
public class Page1
{
#region constructor
public Page1()
{
GoPage2Command = new Command(async () => await GoPage2());
}
private async Task GoPage2()
{
await Application.Current.MainPage.DisplayAlert("", "Goin to page 2", "ok");
//code to go PageNumberTwo here
}
#endregion
#region Commands
public Command GoPage2Command { get; set; }
#endregion
}
GoPage2Command 绑定到一个按钮。 有我完整的项目上传到 MF VS proyect
【问题讨论】:
标签: c# xamarin xamarin.forms