ViewModel is the class that will be responsible for fetching the data and handling the view logic. Because photos will be added asynchronously to the photos collection, we don't want to set IsBusy to false immediately after we call the Get method of PhotoImporter. We will instead wait 3 seconds, first. However, we will also add an event listener to the collection so that we can listen for changes. If the collection changes and there are items in it, we will set IsBusy to false. Add the following code to implement this:
public class GalleryViewModel : ViewModel
{
private readonly IPhotoImporter photoImporter;
private readonly ILocalStorage localStorage;
public GalleryViewModel(IPhotoImporter photoImporter, ILocalStorage localStorage)
{
this.photoImporter = photoImporter;
this.localStorage = localStorage;
Task.Run(Initialize);
}
public ObservableCollection<Photo...