正如您所看到的,我想导航到“ScoreInputDialog.xaml”页面,用户可以在其中键入一个名称。在此之后,我试图将名称保存到列表中,但它总是空的,因为最终导航到页面“ScoreInputDialog.xaml”正在完成。在继续执行其他代码之前,如何导航到期望的页面并获取我的价值?为什么NavigationService.Navigate只在最后运行?
NavigationService.Navigate(new Uri("/ScoreInputDialog.xaml", UriKind.Relative)); // Sets tempPlayerName through a textbox.
if (phoneAppService.State.ContainsKey("tmpPlayerName"))
{
object pName;
if (phoneAppService.State.TryGetValue("tmpPlayerName", out pName))
{
tempPlayerName = (string)pName;
}
}
highScorePlayerList.Add(tempPlayerName);
感谢您的示例和解释。它解决了我的问题。 – Mudasar