protected override void PostResetList() { AddSortDescription( new Microsoft.Toolkit.Uwp.UI.SortDescription("NowLive", Microsoft.Toolkit.Uwp.UI.SortDirection.Descending) ); AddSortDescription( new Microsoft.Toolkit.Uwp.UI.SortDescription("IsTimedOut", Microsoft.Toolkit.Uwp.UI.SortDirection.Ascending) ); AddSortDescription( new Microsoft.Toolkit.Uwp.UI.SortDescription("IsReserved", Microsoft.Toolkit.Uwp.UI.SortDirection.Ascending) ); AddSortDescription( new Microsoft.Toolkit.Uwp.UI.SortDescription("ExpiredAt", Microsoft.Toolkit.Uwp.UI.SortDirection.Ascending) ); IncrementalLoadingItems.ObserveElementPropertyChanged() .Where(x => x.EventArgs.PropertyName == nameof(x.Sender.Reservation) && x.Sender.Reservation == null) .Subscribe(x => { ItemsView.Remove(x.Sender); }); base.PostResetList(); }
public override void OnNavigatedTo(INavigationParameters parameters) { base.OnNavigatedTo(parameters); SelectedSortOptionItem = QueuePlaylist.DefaultSortOption; Observable.Merge( IsEnableGroupingByTitleSimulality.ToUnit(), this.ObserveProperty(x => x.SelectedSortOptionItem, isPushCurrentValueAtFirst: false).ToUnit() ) .Subscribe(sort => ResetList()) .AddTo(_navigationDisposables); _messenger.Register <PlaylistItemRemovedMessage, PlaylistId>(this, QueuePlaylist.Id, (r, m) => { foreach (var item in m.Value.RemovedItems) { var remove = ItemsView.Cast <IVideoContent>().FirstOrDefault(x => x.VideoId == item.VideoId); ItemsView.Remove(remove); } }); _messenger.Register <PlaylistItemAddedMessage, PlaylistId>(this, QueuePlaylist.Id, (r, m) => { ItemsView.Clear(); ItemsView.Refresh(); }); }
protected override void PostResetList() { AddSortDescription( new Microsoft.Toolkit.Uwp.UI.SortDescription(nameof(LiveInfoListItemViewModel.IsOnair), Microsoft.Toolkit.Uwp.UI.SortDirection.Descending) ); AddSortDescription( new Microsoft.Toolkit.Uwp.UI.SortDescription(nameof(LiveInfoListItemViewModel.IsPast), Microsoft.Toolkit.Uwp.UI.SortDirection.Ascending) ); AddSortDescription( new Microsoft.Toolkit.Uwp.UI.SortDescription(nameof(LiveInfoListItemViewModel.IsReserved), Microsoft.Toolkit.Uwp.UI.SortDirection.Ascending) ); AddSortDescription( new Microsoft.Toolkit.Uwp.UI.SortDescription(nameof(LiveInfoListItemViewModel.ExpiredAt), Microsoft.Toolkit.Uwp.UI.SortDirection.Ascending) ); (ItemsView.Source as ObservableCollection <LiveInfoListItemViewModel>).ObserveElementPropertyChanged() .Where(x => x.EventArgs.PropertyName == nameof(x.Sender.Reservation) && x.Sender.Reservation == null) .Subscribe(x => { ItemsView.Remove(x.Sender); }); base.PostResetList(); }
void RefreshItems() { if (Playlist != null) { WeakReferenceMessenger.Default.Register <PlaylistItemRemovedMessage, PlaylistId>(this, Playlist.PlaylistId, (r, m) => { var args = m.Value; foreach (var video in args.RemovedItems) { var removedItem = ItemsView.Cast <VideoListItemControlViewModel>().FirstOrDefault(x => x.VideoId == video.VideoId); if (removedItem != null) { ItemsView.Remove(removedItem); } } PlaylistPlayAllCommand.NotifyCanExecuteChanged(); }); WeakReferenceMessenger.Default.Register <PlaylistItemAddedMessage, PlaylistId>(this, Playlist.PlaylistId, (r, m) => { var args = m.Value; int index = ItemsView.Count; foreach (var video in args.AddedItems) { var nicoVideo = _nicoVideoProvider.GetCachedVideoInfo(video.VideoId); ItemsView.Add(new VideoListItemControlViewModel(nicoVideo) { PlaylistItemToken = new PlaylistItemToken(Playlist, SelectedSortOptionItem, video) }); } PlaylistPlayAllCommand.NotifyCanExecuteChanged(); }); _localMylistManager.LocalPlaylists.ObserveRemoveChanged() .Subscribe(removed => { if (Playlist.PlaylistId == removed.PlaylistId) { _pageManager.ForgetLastPage(); _pageManager.OpenPage(HohoemaPageType.UserMylist); } }) .AddTo(_navigationDisposables); } }