【发布时间】:2011-11-10 17:41:00
【问题描述】:
我有一个带有“内部导航”的页面。这意味着我在该页面上显示一些列表,当用户选择一个项目时,我(下载一些数据并)重新填充该列表。
我创建了自己的历史堆栈,所以当用户想要返回时,我从历史堆栈重新填充列表。用户可以通过轻弹或单击硬件返回按钮返回。
滑动正常,但返回按钮很奇怪。
我正在取消后退按钮事件,而是运行我的后退导航历史记录。所以我仍然在同一页面上。但是后退按钮单击隐藏了应用程序栏(即使我正在取消该事件)。而当我再次点击并调试时,ApplicationBar 属性为空。
// this overriden method causes ApplicationBar being hidden (or destroyed)
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
Messenger.Default.Send(...some notification here...); // this runs the internal navigation
ApplicationBar.IsVisible = true; // this doesn't help and on the second try, it throws NullReferenceException
}
// this method is ok, repopulating is working without any problem
private void GestureListener_Flick(object sender, FlickGestureEventArgs e)
{
Messenger.Default.Send( ...some notification here... ); // this run exactly same internal navigation
}
所以问题是 - 如何让 ApplicationBar 不被破坏/隐藏?当我取消导航时,后退按钮在做什么(它必须对 AppBar 做一些事情)?
【问题讨论】:
-
我无法重新创建这个。您能否发布一个显示此问题的完整示例。
-
哦!我得到它。我忘了提到我使用 BindableApplicatonBar 和 Extensions(来自这里 link)。修改后的 AppBar 为自己处理后退按钮事件。抱歉,混淆了 - 经典的 AppBar 效果很好。感谢您的支持!
标签: windows-phone-7