积极答复者
Windows phone 8.1 中如何取消页面后退?

问题
-
Windows phone 8.1 中如何取消页面后退?
下面的代码似乎不起作用:
private void OnBackPressed(object sender, BackPressedEventArgs e)
{
if (this.ItemsListView.SelectionMode == ListViewSelectionMode.Multiple)
{
this.ItemsListView.SelectionMode = ListViewSelectionMode.None;
e.Handled = true;
}
}- 已移动 Jamles HezModerator 2014年9月1日 1:31
答案
-
解决了。WP8.1 的项目模版里面加入了 NavigationHelper,并且在里面为 HardwareButtons 注册了 BackPressed 事件,因此设置 NavigationHelper 的 GoBackCommand 就可以了。例如。
this.navigationHelper.GoBackCommand = new RelayCommand(() =>
{
if (this.ItemsListView.SelectionMode == ListViewSelectionMode.Multiple)
{
this.ItemsListView.SelectionMode = ListViewSelectionMode.None;
}
else
{
this.navigationHelper.GoBack();
}}, this.navigationHelper.CanGoBack);
- 已标记为答案 JohnSmith1st 2014年9月3日 2:09
全部回复
-
楼主 你好,
请参考:
while(NavigationService.CanGoBack) { NavigationService.RemoveBackEntry(); }
谢谢!
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
解决了。WP8.1 的项目模版里面加入了 NavigationHelper,并且在里面为 HardwareButtons 注册了 BackPressed 事件,因此设置 NavigationHelper 的 GoBackCommand 就可以了。例如。
this.navigationHelper.GoBackCommand = new RelayCommand(() =>
{
if (this.ItemsListView.SelectionMode == ListViewSelectionMode.Multiple)
{
this.ItemsListView.SelectionMode = ListViewSelectionMode.None;
}
else
{
this.navigationHelper.GoBack();
}}, this.navigationHelper.CanGoBack);
- 已标记为答案 JohnSmith1st 2014年9月3日 2:09