正如您所看到的,我想導航到「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