Inheritance: Windows.UI.Xaml.Controls.GridView
Exemple #1
0
        private static void ItemsPanelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            AdaptiveCollectionView obj   = (AdaptiveCollectionView)d;
            ItemsPanelTemplate     value = (ItemsPanelTemplate)e.NewValue;

            obj.SetBaseItemsPanel(value);
        }
Exemple #2
0
        private static async void InternalModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            AdaptiveCollectionView     obj   = (AdaptiveCollectionView)d;
            AdaptiveCollectionViewMode value = (AdaptiveCollectionViewMode)e.NewValue;

            if (Enum.IsDefined(typeof(AdaptiveCollectionViewMode), value) == false)
            {
                throw new ArgumentException($"{nameof(AdaptiveCollectionViewMode)} is not defined", nameof(value));
            }

            int index = -1;

            if (obj.Items.Count > 0)
            {
                ItemsStackPanel stackPanel = obj.ItemsPanelRoot as ItemsStackPanel;
                if (stackPanel != null)
                {
                    index = stackPanel.FirstVisibleIndex;
                }

                ItemsWrapGrid wrapGrid = obj.ItemsPanelRoot as ItemsWrapGrid;
                if (wrapGrid != null)
                {
                    index = wrapGrid.FirstVisibleIndex;
                }
            }

            if (value == AdaptiveCollectionViewMode.List)
            {
                obj.ItemsPanel = obj._itemsStackPanel;
            }
            else
            {
                obj.ItemsPanel = obj._itemsWrapGrid;
            }

            if (obj.ModeChanged != null)
            {
                obj.ModeChanged(obj, new AdaptiveCollectionViewModeChangedEventArgs((AdaptiveCollectionViewMode)e.OldValue, (AdaptiveCollectionViewMode)e.NewValue));
            }

            await obj.WaitForLayoutUpdatedAsync();

            if (obj.SelectedItem != null)
            {
                obj.ScrollIntoView(obj.SelectedItem, ScrollIntoViewAlignment.Leading);
            }
            else if (index > -1)
            {
                var item = obj.Items.ElementAtOrDefault(index);
                if (item != null)
                {
                    obj.ScrollIntoView(item, ScrollIntoViewAlignment.Leading);
                }
            }
        }
Exemple #3
0
        private static void ItemContainerStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            AdaptiveCollectionView obj = (AdaptiveCollectionView)d;
            Style value = (Style)e.NewValue;

            if (value != null)
            {
                if (value.TargetType != typeof(AdaptiveCollectionViewItem))
                {
                    throw new ArgumentException($"the target type of item container style should be {nameof(AdaptiveCollectionViewItem)}", nameof(value));
                }
                else
                {
                    value.TargetType = typeof(GridViewItem);
                }
            }

            obj.SetBaseItemContainerStyle(value);
        }