简体   繁体   中英

How to navigate to the same page with a new instance created on Windows Phone 8.1

How could I navigate from SomePage to another SomePage with a new instance created? Here is my code in ViewModel:

public RelayCommandEx<SomeItemSchema> ItemClickCommand
    {
        get
        {
            if (itemClickCommand == null)
            {
                itemClickCommand = new RelayCommandEx<SomeItemSchema>(
                    (item) =>
                    {
                        NavigationServices.NavigateToPage("SomePage", item);
                    });
            }
            return itemClickCommand;
        }
    }`

Code in CodeBehind of SomePage: 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);
    }

If you want to navigate to a new instance of the same page then just navigate to the same page but give it a different timestamp.

Like so

NavigationService.Navigate(new Uri("/SomePage.xaml?" + DateTime.Now.ToString(), UriKind.Relative));

Now each SomePage will push to the nagivation stack.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM