how to refresh a page in visual studio?

允我心安 提交于 2019-12-25 04:26:37

问题


i have created a windows phone application. In each page i have given a back button using "NavigationService.GoBack()" command. i want that when the back button is pressed the previous page to which it navigate the whole code of that page must again be executed.


回答1:


If you're relying the user pressing the hardware back button you shouldn't have to call GoBack() yourself.

To refresh a page when the user navigates back to it you can use the following in your page (and add the refresh code as appropriate):

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    base.OnNavigatedTo(e);

    if (e.NavigationMode == NavigationMode.Back)
    {
        // Do your refreshing here
    }
}


来源:https://stackoverflow.com/questions/23512554/how-to-refresh-a-page-in-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!