So, I'm starting to wonder if I've got the general concept / structure wrong!
I am using the latest Xamarin Forms and Shell structure.
There are a number of pages that show different data (obtained via an API from our website), but let's take one - a list of "Devices".
I have a page that gets the devices for the current user and displays in a list. The list is defined in the DevicesPageViewModel as:
public ObservableCollection<UserDevice> Items { get; set; }
A Device can, among other things, be Activated by entering a code. This code is entered on a DeviceActivation page, which I get to by using
await Shell.Current.GoToAsync($"{nameof(DeviceActivatePage)}");
in response to a button click.
My question is, after the device has been activated on the "DeviceActivatePage", how do I update the DevicesPage so that the Device now shows as Activated?
I have been looking at a basic app that Visual Studio 2019 created, and it uses a BaseViewModel that has a "public DataStore" of items. When you add an item and are returned to the list page, the new item appears. I assume this is because the list of Items is defined as "ObservableCollection<Item>" in the list page ViewModel.
I am not sure that storing my list of Devices in the BaseViewModel is a good idea, as I would need a few other lists too? Or is that OK / the way to do it? Is there any issues with the amount of data being stored in the BaseViewModel?
I did think about passing parameters back with the "Shell.Current.GoToAsync("..");" command in the Device Details page. Or using MessagingCenter to send a message to the list page to tell it to update? Both of those options seem messy!
I appreciate I haven't added much code to this post, but this isn't really a coding problem, more a concept / structure / methodology question. I hope someone can help me :-)