簡體   English   中英

頁面導航Windows Phone 8.1

[英]Page Navigation Windows Phone 8.1

Windows Phone 8.1中的頁面導航是:

Frame.Navigate(typeof(SecondPage));

或帶有參數:

Frame.Navigate(typeof(SecondPage), param);

並在目標頁面上:

protected override void OnNavigatedTo(NavigationEventArgs e)
{
  myTextBox.Text = e.Parameter.ToString();
}

要么

protected override void OnNavigatedTo(NavigationEventArgs e)
{
  var val = (myClass)e.Parameter;
  myTextBox.Text = val.Text;
}

但就我而言,我想對目標頁面上收到的數據進行處理。 例如,我想讓用戶編輯這些數據並將其另存為新數據。 我已經搜索了幾個小時,而我所能找到的只是帶有或不帶有參數的頁面導航,而不是上面描述的頁面導航。 有什么辦法可以解決這個問題? 任何建議,解決方案表示贊賞!

要將文本和設置名稱傳遞到編輯表單,請使用KeyValuePair:

//figure out how to get the text out of the list
var myItem = new KeyValuePair<string, string>("mytextsetting", "listbox.selecteditem.text");
Frame.Navigate(typeof(SecondPage), myItem);

現在,在第二頁上,可以存儲傳入的參數:

KeyValuePair<string, string> _myItem;

protected override void OnNavigatedTo(NavigationEventArgs e)
{
   _myItem = e.Parameter as KeyValuePair<string, string>;
   myTextBox.Text = myItem.Value;
}

現在,當用戶想要保存編輯后的文本時:

_myItem.Value = myTextBox.Text;

//save it to the settings
localSettings.Values[_myItem.Key] = _myItem.Value;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM