单击后退按钮(WP7)刷新或更新页面 [英] Refresh Or Update Page on click of back button (WP7)

查看:84
本文介绍了单击后退按钮(WP7)刷新或更新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用中使用了标准导航服务,但问题是

I have used the standard navigation service in my app but the problem is

帐户页面(显示数据上下文中的信息)->添加帐户页面

Accounts Page (Show info from datacontext) -> Add Accounts Page

现在,如果我从添加帐户页面导航到帐户页面",它会如下创建新的帐户页面"实例

now if i give navigation to Accounts Page from Add Accounts Page it creates new instance of Accounts Page as below

帐户页面(旧数据)->添加帐户页面->帐户页面(更新数据)

Accounts Page (Old Data) -> Add Accounts Page -> Accounts Page (Updated Data)

当我进入新实例时,页面上的数据将显示新条目,但如果返回,我将再次进入添加帐户页面&然后不显示更新后的条目的帐户页面"(旧数据),因此我必须返回首页分页&再次导航到帐户页面"以进行更新,因此我该怎么做才能使添加帐户页面"保存按钮将我发送回帐户页面"和我的帐户".它的更新了吗?

when i get to the new instance the data on the page shows the new entry but if get back i get to the add accounts page again & then Accounts Page (Old Data) which does not show the updated entryso i have to get back to the home pag & again navigate to Accounts Page to get it updated so what should i do to make Add Accounts Page save button send me back to the Accounts Page & its updated?

我尝试过

NavigationService.GoBack();

NavigationService.GoBack();

NavigationService.RemoveBackEntry();

NavigationService.RemoveBackEntry();

NavigationService.Navigate(新的Uri(string.Format("/Accounts.xaml?Refresh = true"),UriKind.Relative));

NavigationService.Navigate(new Uri(string.Format("/Accounts.xaml?Refresh=true"), UriKind.Relative));

但是没有任何效果,请帮助

but nothing worked as i wanted PLEASE HELP

推荐答案

NavigationService.GoBack();是正确的方法.您需要关注的问题是:如何在返回帐户"页面时刷新数据".解决方案取决于您的应用程序的体系结构.如果您使用了MVVM模式,则只需将新帐户添加到视图模型中的数据源即可.否则,您可能应该在页面的OnNavigatedTo方法中重新加载帐户列表:

NavigationService.GoBack(); is the right way. The problem you need to focus on is: "how to refresh the data when going back to the Accounts Page". The solution depends on your application's architecture. If you used the MVVM pattern, then it's just a matter of adding the new account to the data source in the viewmodel. Otherwise, you should probably reload the account list in the OnNavigatedTo method of your page:

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    // Load the accounts
}

这篇关于单击后退按钮(WP7)刷新或更新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆