【发布时间】:2017-10-09 09:07:40
【问题描述】:
Xamarin ToolBarItem 点击事件不重定向页面
这是我的代码
.xamal
<ContentPage.ToolbarItems>
<ToolbarItem Name="MenuItem1" Command="{Binding HomeMenuCommand}" Order="Primary" Icon="tab_home.png.png" Text="Home" Priority="0" />
</ContentPage.ToolbarItems>
视图模型
public ICommand HomeMenuCommand { get; }
public AboutViewModel()
{
Title = "About";
HomeMenuCommand = new Command(async () => await GoToHomeCommand());
}
async Task GoToHomeCommand()
{
await this.PushPageFromCacheAsync<MainViewModel>();
}
此页面位于 TopOf 选项卡式页面上,我正在使用 Xamvvm 来查看模型绑定
当我放
await Application.Current.MainPage.DisplayAlert("test...", "test", "OK");
在 GoToHomeCommand() 消息内部,警报生成
请帮我解决
【问题讨论】:
-
试试
bool success = await PushPageFromCacheAsync<MainViewModel>();有什么错误代码什么的? -
没有任何错误代码...
标签: xamarin xamarin.ios xamarin.forms xamarin.android