Load data at Startup
Our backend code provides a nice way to load the users collection from disk.
Add a method to
private async void LoadAlbums()
var albums = (await Album.LoadCachedAsync()).Select(x => new AlbumViewModel(x));
foreach (var album in albums)
foreach (var album in Albums.ToList())
Register it in the constructor of the same class like:
If you get an error about "Cannot resolve method Schedule", you may be missing the line
MainWindowViewModel's using section.
As you can see it firstly uses the business logic apis to load the list of
Albums. It then transforms each one into an
AlbumViewModel. After this we add each
AlbumViewModelinstance to the
Albums, this will instantly update the UI.
Note we then re-iterate over the
Albumsand asynchronously load each cover. Note that we do this after adding all the albums to the list, as its more important to quickly show the user all the albums available and then load the images.