So I have a page with a list that pulls data from the database, then I navigate to another page that adds something to the database, then I pop back to the previous page but want to run the refresh command to pull from the database again.
I can't figure out how to do this. Any ideas?
Thank you!
ps. I'm new to MVVM so please be gentle...
Posts
Override the OnAppearing event and refresh there.
protected override void OnAppearing()
{
base.OnAppearing();
I would, but I'm trying to keep things in the view model. Currently I have a method in the viewmodel "PopulateList()" I'd like that to run on appearing. I would just run an execute, but the viewmodel takes parameters from the previous viewmodel. Maybe I'm not passing things between viewmodels properly, but it's the only way I know how to do it.
Thanks.
bump
the way I have it set up, the viewmodel takes in parameters. Maybe there's a way to do it, if so I'm all ears.
Thanks
Well, basically, it's a program that needs to be signed into, it's passing the current username of who is logged in for keeping track in the database.
I am new to MVVM, maybe you have a better idea on how i could do this?
Thanks
I see, so your text entries should be bound to properties on your vm. Then your vm contains all of its state.
There are quite a few examples of MVVM with Xamarin.Forms available, it might be best to start there.
I have everything bound into the VMs, and I do all database stuff and basically everything in the vm. but I don't really know what else to do. So I just passed with the pushasync like this: Application.Current.MainPage.Navigation.PushAsync(new frmAdmin(strCurrentUser));
If you have everything already bound, then you already have the properties for your PopulateList method, no?
As I said, take a look at the examples, they should help you understand how it all works.
I'll look into it! I may ask questions after I read them tomorrow. Thanks for your help!