简体   繁体   English

Navigation.PopAsync暂时显示旧页面

[英]Navigation.PopAsync showing the old page for a moment

I am calling Navigation.PopAsync to call the previous page. 我正在调用Navigation.PopAsync来调用上一页。 But, on the OnAppearing method of the previous page, I am refreshing data of listview by setting itemssource. 但是,在OnAppearing方法上,我正在通过设置itemssource刷新listview的数据。 But when calling popasync I am able to see the previous page with old data for a moment. 但是,当调用popasync时,我可以暂时查看包含旧数据的上一页。 After a moment the page refreshes and shows the correct data. 片刻之后,页面刷新并显示正确的数据。 Is there any way to hide the old data being shown? 有什么方法可以隐藏显示的旧数据吗?

You could add bool DataLoaded property which implements OnPropertyChanged to your view model. 您可以将实现OnPropertyChanged bool DataLoaded属性添加到视图模型。 Then bind this property to yours page Content.IsVisibleProperty . 然后将此属性绑定到您的页面Content.IsVisibleProperty When you start refreshing your data simply set DataLoaded to false , and after it finishes set it to true . 开始刷新数据时,只需将DataLoaded设置为false ,完成后将其设置为true You could also add an ActivityIndicator for a better user experience ( http://developer.xamarin.com/api/type/Xamarin.Forms.ActivityIndicator ) 您还可以添加ActivityIndi​​cator以获得更好的用户体验( http://developer.xamarin.com/api/type/Xamarin.Forms.ActivityIndi​​cator

See Data Binding chapter: http://developer.xamarin.com/guides/cross-platform/xamarin-forms/introduction-to-xamarin-forms/ 请参阅“数据绑定”一章: http : //developer.xamarin.com/guides/cross-platform/xamarin-forms/introduction-to-xamarin-forms/

I removed listview in OnDisappearing method. 我在OnDisappearing方法中删除了listview。 Now, It is working correctly. 现在,它可以正常工作。 It does not show old data any more. 它不再显示旧数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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