using System.Threading.Tasks;
using OwlCore.Extensions;
using StrixMusic.Sdk.ViewModels;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace StrixMusic.Sdk.WinUI.Controls.Views.Secondary
{
///
/// A Templated for showing an as a page.
///
public sealed partial class AlbumView : Control
{
///
/// Initializes a new instance of the class.
///
/// The Album in view.
public AlbumView(AlbumViewModel albumViewModel)
{
this.DefaultStyleKey = typeof(AlbumView);
Album = albumViewModel;
LoadAsync().Forget();
}
///
/// ViewModel holding the data for
///
public AlbumViewModel Album
{
get { return (AlbumViewModel)GetValue(AlbumProperty); }
set { SetValue(AlbumProperty, value); }
}
///
/// Dependency property for .
///
// Using a DependencyProperty as the backing store for ViewModel. This enables animation, styling, binding, etc...
public static readonly DependencyProperty AlbumProperty =
DependencyProperty.Register(nameof(Album), typeof(ArtistViewModel), typeof(AlbumView), new PropertyMetadata(0));
private async Task LoadAsync()
{
if (!Album.PopulateMoreArtistsCommand.IsRunning)
await Album.PopulateMoreArtistsCommand.ExecuteAsync(25);
if (!Album.PopulateMoreTracksCommand.IsRunning)
await Album.PopulateMoreTracksCommand.ExecuteAsync(25);
}
}
}