fix spacing and add a message when empty.
This commit is contained in:
Родитель
b56116bf15
Коммит
37f4885c0e
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.ObjectModel;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reactive.Concurrency;
|
||||
using System.Reactive.Linq;
|
||||
|
@ -9,6 +10,8 @@ namespace Avalonia.MusicStore.ViewModels
|
|||
{
|
||||
public class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
private bool _collectionEmpty;
|
||||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
ShowDialog = new Interaction<MusicStoreViewModel, AlbumViewModel?>();
|
||||
|
@ -25,9 +28,18 @@ namespace Avalonia.MusicStore.ViewModels
|
|||
}
|
||||
});
|
||||
|
||||
this.WhenAnyValue(x => x.Albums.Count)
|
||||
.Subscribe(x => CollectionEmpty = x == 0);
|
||||
|
||||
RxApp.MainThreadScheduler.Schedule(LoadAlbums);
|
||||
}
|
||||
|
||||
public bool CollectionEmpty
|
||||
{
|
||||
get => _collectionEmpty;
|
||||
set => this.RaiseAndSetIfChanged(ref _collectionEmpty, value);
|
||||
}
|
||||
|
||||
private async void LoadAlbums()
|
||||
{
|
||||
var albums = await AlbumViewModel.LoadCached();
|
||||
|
@ -37,6 +49,7 @@ namespace Avalonia.MusicStore.ViewModels
|
|||
Albums.Add(album);
|
||||
}
|
||||
|
||||
|
||||
LoadCovers();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Avalonia.MusicStore.ViewModels
|
||||
{
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Avalonia.MusicStore.Views.MainWindow"
|
||||
xmlns:local="using:Avalonia.MusicStore.Views"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Background="Transparent"
|
||||
TransparencyLevelHint="AcrylicBlur"
|
||||
|
@ -32,12 +33,20 @@
|
|||
<PathIcon Data="{StaticResource store_microsoft_regular}" />
|
||||
</Button>
|
||||
|
||||
<ItemsControl Items="{Binding Albums}">
|
||||
<TextBlock IsVisible="{Binding CollectionEmpty}" Text="Its lonely in here. Purchase some music to get your collection started." HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
|
||||
<ItemsControl Margin="0 40 0 0" Items="{Binding Albums}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<local:AlbumView Margin="0 0 20 20" />
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</Panel>
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче