Пример #1
0
        /// <summary>
        /// Update all grouping options. This method is intended to be called only from parent view.
        /// </summary>
        /// <param name="stateManager">The new state manager for the hosted page.</param>
        public void ReloadGroupingOptions(IPageGroupingStateManager stateManager)
        {
            IsNavigationOpsAvailable = false;

            _stateManager = stateManager;
            SortingOptions.Clear();

            // Reload options
            var options = _stateManager.PopulateAvailablePairs();

            foreach (var option in options)
            {
                SortingOptions.Add(option);
            }

            // Set default option
            // We don't need to set it - it is already passed to view
            var lastUsedOption = _stateManager.GetLastUsedPair();
            var elem           = SortingOptions.Where(i => i.Identifier == lastUsedOption.Identifier).ToList();

            if (elem.Any())
            {
                SelectedItemIndex = SortingOptions.IndexOf(elem.FirstOrDefault());
            }

            // Enable selection
            IsNavigationOpsAvailable = true;
        }
Пример #2
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            _cts = new CancellationTokenSource();
            if (ViewModel == null)
            {
                var type = (CommonItemType)e.Parameter;
                ContentGridView.ItemTemplate = (DataTemplate)Resources[ResourceName[type]];
                if (type == CommonItemType.Song)
                {
                    var collection = Resources["AlternatingColorBehavior"] as BehaviorCollection;
                    collection.Attach(ContentGridView);
                    _groupState = new PageGroupingStateManager <CommonGroupedListView>(type);
                }
                else
                {
                    _groupState = new PageGroupingStateManager <CommonGroupedGridView>(type);
                }
                // Reload options
                SortingOptions.Clear();
                var options = _groupState.PopulateAvailablePairs();
                foreach (var option in options)
                {
                    SortingOptions.Add(option);
                }

                var lastUsedOption = _groupState.GetLastUsedPair();
                var elem           = SortingOptions.Where(i => i.Identifier == lastUsedOption.Identifier).ToList();
                if (elem.Any())
                {
                    SortingMethod = SortingOptions.IndexOf(elem.FirstOrDefault());
                }
                DataContext = new LibraryViewModel(new DataObjects.GroupedViewNavigationArgs(type, lastUsedOption));

                GroupedCvs.Source          = ViewModel.GroupedItems.Items;
                GroupedCvs.IsSourceGrouped = true;

                await ViewModel.LoadDataAsync(_cts.Token);
            }
            Messenger.Default.Register <MessageBase>(this, CommonSharedStrings.IndexFinishedMessageToken, OnIndexFinished);

            if (_previousAnimatedControl != null)
            {
                var imageAnimation = ConnectedAnimationService.GetForCurrentView().GetAnimation("image");
                imageAnimation?.TryStart(_previousAnimatedControl);
                _previousAnimatedControl = null;
            }
        }