我正在设计一个Windows 8 Metro阅读应用程序,并在正确的开始时遇到导航事件问题。为了简化问题,描述如下:Windows 8应用程序中的GoBack()事件dev
有两个页面:MainPage.xaml和DetailPage.xaml。 MainPage.xaml包含一个列表视图,该项目是一个文章对象(从Web上下载文章项目),一个项目被点击。该帧将使用
void ItemView_ItemClick(object sender, ItemClickEventArgs e)
{
// Navigate to the appropriate destination page, configuring the new page
// by passing required information as a navigation parameter
this.Frame.Navigate(typeof(DetailPage), e.ClickedItem);
}
阅读整篇文章后,用户将点击“GoBack的”按钮,它被定义为
<Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
那么问题来了,它应该使框架刚刚导航回到MainPage,但在导航之后,缺少MainPage中的DataContext,并再次调用MainPage的构造函数,从而获取Web资源。
作为一名Windows Phone开发人员,我对这个问题感到困惑。有人能帮助我吗?
在此先感谢。
谢谢,菲利普。它按预期工作。 – ellic