【问题标题】:Xamarin ToolBarItem click event not redirecting pageXamarin ToolBarItem 单击事件未重定向页面
【发布时间】: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&lt;MainViewModel&gt;();有什么错误代码什么的?
  • 没有任何错误代码...

标签: xamarin xamarin.ios xamarin.forms xamarin.android


【解决方案1】:

虽然我还没有尝试过 Xamvvm,但看看你的问题,你的命令似乎工作正常。唯一的问题是重定向。

你试过这个吗?

async Application.MainPage.Current = new NavigationPage(new YourPage());

【讨论】:

  • sry 这也是同样的问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-05
  • 2016-11-14
  • 1970-01-01
  • 1970-01-01
  • 2021-03-15
  • 2011-08-15
相关资源
最近更新 更多