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.
@KylukeMcDougall - I'd be tempted to use Messaging Center. Have the page that contains the ListView subscribe to messages. Send a message from OnResume. When the subscriber receives it, have it do whatever operations are required to retrieve the latest data, and then update the collection that the ListView is bound to.
Answers
@KylukeMcDougall - I'd be tempted to use Messaging Center. Have the page that contains the ListView subscribe to messages. Send a message from OnResume. When the subscriber receives it, have it do whatever operations are required to retrieve the latest data, and then update the collection that the ListView is bound to.
@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) => {});