Merge remote-tracking branch 'origin/patch-3' into patch-2

This commit is contained in:
Miguel Guthridge 2021-05-20 12:16:56 +10:00
Родитель 8f352df74d 9c62fc0ef6
Коммит e62536aa62
2 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -64,6 +64,14 @@ namespace Avalonia.MusicStore.ViewModels
get => _cover;
private set => this.RaiseAndSetIfChanged(ref _cover, value);
}
public async Task LoadCover()
{
await using (var imageStream = await _album.LoadCoverBitmapAsync())
{
Cover = await Task.Run(() => Bitmap.DecodeToWidth(imageStream, 400));
}
}
}
}
```

Просмотреть файл

@ -18,7 +18,7 @@ public ReactiveCommand<Unit, AlbumViewModel?> BuyMusicCommand { get; }
Note we are using `ReactiveCommand` this is where we are using ReactiveUI to provide some of the plumbing for us. Avalonia expects commands to be of type `ICommand` and `ReactiveCommand` implements this interface.
Note that `ReactiveCommand<TParam, TResult>` has some type arguments. Commands can take a parameter, however we do not need a paramter in this case, so we use `Unit` which is kind of a dummy type, it contains no data. Reactive Commands can also return a result. This sill be useful for returning the Album the user wants to buy.
Note that `ReactiveCommand<TParam, TResult>` has some type arguments. Commands can take a parameter, however we do not need a paramter in this case, so we use `Unit` which is kind of a dummy type, it contains no data. Reactive Commands can also return a result. This will be useful for returning the Album the user wants to buy.
Now add a constructor to `MusicStoreViewModel` where we can instantiate the command, and implement the code needed to return a result from the dialog.