[英]How to navigate to the same page with a new instance created on Windows Phone 8.1
創建新實例后,如何從SomePage導航到另一個SomePage? 這是我在ViewModel中的代碼:
public RelayCommandEx<SomeItemSchema> ItemClickCommand
{
get
{
if (itemClickCommand == null)
{
itemClickCommand = new RelayCommandEx<SomeItemSchema>(
(item) =>
{
NavigationServices.NavigateToPage("SomePage", item);
});
}
return itemClickCommand;
}
}`
SomePage的CodeBehind中的代碼: this.NavigationCacheMode = NavigationCacheMode.Enabled;
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
_navigationHelper.OnNavigatedTo(e);
SomeItemSchema parameter = e.Parameter as SomeItemSchema;
SomeItemModel.SelectItem(parameter);
await SomeItemModel.LoadItemsAsync(parameter.Url);
}
如果要導航到同一頁面的新實例,則只需導航到同一頁面,但為其指定不同的時間戳即可。
像這樣
NavigationService.Navigate(new Uri("/SomePage.xaml?" + DateTime.Now.ToString(), UriKind.Relative));
現在,每個SomePage將推送到導航堆棧。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.