Refresh ListView OnResume

KylukeMcDougallKylukeMcDougall USMember ✭✭
edited September 2017 in Xamarin.Forms

How do I tricker a ListView refresh OnResume?

This is a ListView in a ContentPage that also needs to pull fresh data from a SQLite database.

So when the person resumes the app, this should trigger a function that grabs the data again from the SQLite database and updates the ListView. The last part (grabbing from db and updating) is not a problem but it's at the moment only being triggered by the page loading and a pull to refresh function.

Tagged:

Best Answer

Answers

  • @JohnHardman - I had a look into that, however I can't seem to get it to send via the message center to the page that is loaded.

    I tried to pop this into OnResume:
    MessagingCenter.Send<MainPage>(this, "listRefresh");

    But the problem with that, is that it I get the following error on this in the line above.

    "cannot convert from *.App to *.MainPage". Any ideas what I am perhaps doing wrong?

    App == public class App : Application
    MainPage == public partial class MainPage : ContentPage

    MainPage is the Navigation Root.

  • I swapped it around and it seems to be working.

    MessagingCenter.Send<App>(this, "listRefresh");

    Then in the MainPage

    MessagingCenter.Subscribe<App>(this, "listRefresh", (sender) => {});

Sign In or Register to comment.