public HeaderFooterTemplate()
        {
            InitializeComponent();

            CollectionView.ItemTemplate = ExampleTemplates.PhotoTemplate();

            BindingContext = new HeaderFooterDemoModel();
        }
        public PreselectedItemGallery()
        {
            InitializeComponent();

            CollectionView.ItemTemplate = ExampleTemplates.PhotoTemplate();
            CollectionView.ItemsSource  = _demoFilteredItemSource.Items;

            CollectionView.SelectedItem = _demoFilteredItemSource.Items.Skip(2).First();
        }
Beispiel #3
0
        public EmptyViewViewGallery()
        {
            InitializeComponent();

            CollectionView.ItemTemplate = ExampleTemplates.PhotoTemplate();

            CollectionView.ItemsSource = _demoFilteredItemSource.Items;

            SearchBar.SearchCommand = new Command(() => _demoFilteredItemSource.FilterItems(SearchBar.Text));
        }
        public EmptyViewStringGallery()
        {
            InitializeComponent();

            CollectionView.ItemTemplate = ExampleTemplates.PhotoTemplate();

            CollectionView.ItemsSource = _demoFilteredItemSource.Items;

            SearchBar.TextChanged += SearchBarOnTextChanged;
        }
        public EmptyViewLoadSimulateGallery()
        {
            InitializeComponent();

            CollectionView.ItemTemplate = ExampleTemplates.PhotoTemplate();

            new Thread(() =>
            {
                Thread.Sleep(1000);
                Device.BeginInvokeOnMainThread(() => CollectionView.ItemsSource = _demoFilteredItemSource.Items);
            }).Start();
        }
Beispiel #6
0
        public ScrollModeTestGallery()
        {
            InitializeComponent();

            var scrollModeSelector = new EnumSelector <ItemsUpdatingScrollMode>(() => CollectionView.ItemsUpdatingScrollMode,
                                                                                mode => CollectionView.ItemsUpdatingScrollMode = mode, "SelectScrollMode");

            Grid.Children.Add(scrollModeSelector);

            CollectionView.ItemTemplate = ExampleTemplates.PhotoTemplate();
            CollectionView.ItemsSource  = _demoFilteredItemSource.Items;
        }
        public PreselectedItemsGallery()
        {
            InitializeComponent();

            CollectionView.ItemTemplate = ExampleTemplates.PhotoTemplate();
            CollectionView.ItemsSource  = _demoFilteredItemSource.Items;

            CollectionView.SelectedItems.Add(_demoFilteredItemSource.Items.Skip(2).First());
            CollectionView.SelectedItems.Add(_demoFilteredItemSource.Items.Skip(4).First());
            CollectionView.SelectedItems.Add(_demoFilteredItemSource.Items.Skip(5).First());

            CollectionView.SelectionMode = SelectionMode.Multiple;
        }
Beispiel #8
0
        public EmptyViewSwapGallery()
        {
            InitializeComponent();

            CollectionView.ItemTemplate = ExampleTemplates.PhotoTemplate();

            CollectionView.ItemsSource = _demoFilteredItemSource.Items;

            SearchBar.TextChanged += SearchBarTextChanged;

            EmptyViewSwitch.Toggled += EmptyViewSwitchToggled;

            SwitchEmptyView();
        }
        public EmptyViewLoadSimulateGallery()
        {
            InitializeComponent();

            CollectionView.ItemTemplate = ExampleTemplates.PhotoTemplate();

            Task.Run(async() =>
            {
                await Task.Delay(1000);
                Dispatcher.Dispatch(() => CollectionView.ItemsSource = new List <object>());
                await Task.Delay(1000);
                Dispatcher.Dispatch(() => CollectionView.ItemsSource = _demoFilteredItemSource.Items);
            });
        }
        public EmptyViewTemplateGallery()
        {
            InitializeComponent();

            CollectionView.ItemTemplate = ExampleTemplates.PhotoTemplate();

            CollectionView.ItemsSource = _demoFilteredItemSource.Items;
            CollectionView.EmptyView   = _emptyViewGalleryFilterInfo;

            SearchBar.SearchCommand = new Command(() =>
            {
                _demoFilteredItemSource.FilterItems(SearchBar.Text);
                _emptyViewGalleryFilterInfo.Filter = SearchBar.Text;
            });
        }
        public SelectionModeGallery()
        {
            InitializeComponent();

            CollectionView.ItemTemplate = ExampleTemplates.PhotoTemplate();
            CollectionView.ItemsSource  = _demoFilteredItemSource.Items;

            var selectionModeSelector = new EnumSelector <SelectionMode>(() => CollectionView.SelectionMode,
                                                                         mode => CollectionView.SelectionMode = mode);

            Grid.Children.Add(selectionModeSelector);

            CollectionView.SelectionChanged       += CollectionViewOnSelectionChanged;
            CollectionView.SelectionChangedCommand = new Command(() =>
                                                                 SelectedItemsCommand.Text =
                                                                     $"SelectionChangedCommand, selection is: {((CollectionViewGalleryTestItem)CollectionView.SelectedItem).Caption}");
        }
Beispiel #12
0
        public EmptyViewSwapGallery()
        {
            InitializeComponent();

            CollectionView.ItemTemplate = ExampleTemplates.PhotoTemplate();

            CollectionView.ItemsSource = _demoFilteredItemSource.Items;

            SearchBar.SearchCommand = new Command(() =>
            {
                _demoFilteredItemSource.FilterItems(SearchBar.Text);
            });

            EmptyViewSwitch.Toggled += EmptyViewSwitchToggled;

            SwitchEmptyView();
        }
Beispiel #13
0
        public SelectionModeGallery()
        {
            InitializeComponent();

            CollectionView.ItemTemplate = ExampleTemplates.PhotoTemplate();
            CollectionView.ItemsSource  = _demoFilteredItemSource.Items;

            var selectionModeSelector = new EnumSelector <SelectionMode>(() => CollectionView.SelectionMode,
                                                                         mode => CollectionView.SelectionMode = mode);

            Grid.Children.Add(selectionModeSelector);

            CollectionView.SelectionChanged       += CollectionViewOnSelectionChanged;
            CollectionView.SelectionChangedCommand = new Command(UpdateSelectionInfoCommand);

            UpdateSelectionInfo(Enumerable.Empty <CollectionViewGalleryTestItem>(), Enumerable.Empty <CollectionViewGalleryTestItem>());
            UpdateSelectionInfoCommand();
        }
        public ObservableCollectionResetGallery()
        {
            var layout = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Star
                    }
                }
            };

            var itemsLayout = new GridItemsLayout(3, ItemsLayoutOrientation.Vertical) as IItemsLayout;

            var itemTemplate = ExampleTemplates.PhotoTemplate();

            var collectionView = new CollectionView {
                ItemsLayout = itemsLayout, ItemTemplate = itemTemplate
            };

            var generator = new ItemsSourceGenerator(collectionView, 100, ItemsSourceType.MultiTestObservableCollection);

            layout.Children.Add(generator);

            var resetter = new Resetter(collectionView);

            layout.Children.Add(resetter);
            Grid.SetRow(resetter, 1);

            layout.Children.Add(collectionView);
            Grid.SetRow(collectionView, 2);

            Content = layout;

            generator.GenerateItems();
        }
        public EmptyViewViewGallery()
        {
            InitializeComponent();

            CollectionView.ItemTemplate = ExampleTemplates.PhotoTemplate();

            CollectionView.ItemsSource = _demoFilteredItemSource.Items;

            SearchBar.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == nameof(SearchBar.Text))
                {
                    if (string.IsNullOrEmpty(SearchBar.Text))
                    {
                        _demoFilteredItemSource.FilterItems(SearchBar.Text);
                    }
                }
            };
            SearchBar.SearchCommand = new Command(() => _demoFilteredItemSource.FilterItems(SearchBar.Text));
        }
Beispiel #16
0
        public ScrollModeTestGallery(IItemsLayout itemsLayout = null, Func <DataTemplate> dataTemplate = null, Func <CollectionView> createCollectionView = null)
        {
            InitializeComponent();

            _collectionView             = createCollectionView == null ? new CollectionView() : createCollectionView();
            _collectionView.ItemsLayout = itemsLayout ?? LinearItemsLayout.Vertical;

            var scrollModeSelector = new EnumSelector <ItemsUpdatingScrollMode>(() => _collectionView.ItemsUpdatingScrollMode,
                                                                                mode => _collectionView.ItemsUpdatingScrollMode = mode, "SelectScrollMode");

            Grid.Children.Add(scrollModeSelector);


            Grid.Children.Add(_collectionView);
            Grid.SetRow(_collectionView, 5);

            _collectionView.ItemTemplate = dataTemplate == null?ExampleTemplates.PhotoTemplate() : dataTemplate();

            _collectionView.ItemsSource = _demoFilteredItemSource.Items;
        }
        public TemplateCodeCollectionViewGridGallery(ItemsLayoutOrientation orientation = ItemsLayoutOrientation.Vertical)
        {
            var layout = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Star
                    }
                }
            };

            var itemsLayout = new GridItemsLayout(2, orientation);

            var itemTemplate = ExampleTemplates.PhotoTemplate();

            var collectionView = new CollectionView {
                ItemsLayout = itemsLayout, ItemTemplate = itemTemplate, AutomationId = "collectionview"
            };

            var generator  = new ItemsSourceGenerator(collectionView, 100);
            var spanSetter = new SpanSetter(collectionView);

            layout.Children.Add(generator);
            layout.Children.Add(spanSetter);
            Grid.SetRow(spanSetter, 1);
            layout.Children.Add(collectionView);
            Grid.SetRow(collectionView, 2);

            Content = layout;

            spanSetter.UpdateSpan();
            generator.GenerateItems();
        }
Beispiel #18
0
        public ObservableCodeCollectionViewGallery(ItemsLayoutOrientation orientation = ItemsLayoutOrientation.Vertical,
                                                   bool grid = true, int initialItems = 1000, bool addItemsWithTimer = false)
        {
            var layout = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Star
                    }
                }
            };

            IItemsLayout itemsLayout = grid
                                ? new GridItemsLayout(3, orientation)
                                : new ListItemsLayout(orientation) as IItemsLayout;

            var itemTemplate = ExampleTemplates.PhotoTemplate();

            var collectionView = new CollectionView {
                ItemsLayout = itemsLayout, ItemTemplate = itemTemplate, AutomationId = "collectionview"
            };
Beispiel #19
0
        public TemplateCodeCollectionViewGallery(IItemsLayout itemsLayout)
        {
            var layout = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Star
                    }
                }
            };

            var itemTemplate = ExampleTemplates.PhotoTemplate();

            var collectionView = new CollectionView
            {
                ItemsLayout     = itemsLayout,
                ItemTemplate    = itemTemplate,
                AutomationId    = "collectionview",
                BackgroundColor = Color.Red
            };

            var generator = new ItemsSourceGenerator(collectionView, initialItems: 20);

            layout.Children.Add(generator);
            layout.Children.Add(collectionView);

            Grid.SetRow(collectionView, 1);

            Content = layout;

            generator.GenerateItems();
        }
        public ObservableCodeCollectionViewGallery(ItemsLayoutOrientation orientation = ItemsLayoutOrientation.Vertical,
                                                   bool grid = true, int initialItems = 1000, bool addItemsWithTimer = false, ItemsUpdatingScrollMode scrollMode = ItemsUpdatingScrollMode.KeepItemsInView)
        {
            var layout = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Star
                    }
                }
            };

            IItemsLayout itemsLayout = grid
                                ? new GridItemsLayout(3, orientation)
                                : new LinearItemsLayout(orientation) as IItemsLayout;

            var itemTemplate = ExampleTemplates.PhotoTemplate();

            var collectionView = new CollectionView {
                ItemsLayout  = itemsLayout, ItemTemplate = itemTemplate,
                AutomationId = "collectionview", Header = "This is the header", ItemsUpdatingScrollMode = scrollMode
            };

            var generator = new ItemsSourceGenerator(collectionView, initialItems, ItemsSourceType.ObservableCollection);

            var remover  = new ItemRemover(collectionView);
            var adder    = new ItemAdder(collectionView);
            var replacer = new ItemReplacer(collectionView);
            var mover    = new ItemMover(collectionView);
            var inserter = new ItemInserter(collectionView);

            layout.Children.Add(generator);

            layout.Children.Add(remover);
            Grid.SetRow(remover, 1);

            layout.Children.Add(adder);
            Grid.SetRow(adder, 2);

            layout.Children.Add(replacer);
            Grid.SetRow(replacer, 3);

            layout.Children.Add(mover);
            Grid.SetRow(mover, 4);

            layout.Children.Add(inserter);
            Grid.SetRow(inserter, 5);

            layout.Children.Add(collectionView);
            Grid.SetRow(collectionView, 6);

            Content = layout;

            if (addItemsWithTimer)
            {
                generator.GenerateEmptyObservableCollectionAndAddItemsEverySecond();
            }
            else
            {
                generator.GenerateItems();
            }
        }
        public ObservableCodeCollectionViewGallery(ItemsLayoutOrientation orientation = ItemsLayoutOrientation.Vertical,
                                                   bool grid = true)
        {
            var layout = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Star
                    }
                }
            };

            IItemsLayout itemsLayout = grid
                                ? new GridItemsLayout(3, orientation)
                                : new ListItemsLayout(orientation) as IItemsLayout;

            var itemTemplate = ExampleTemplates.PhotoTemplate();

            var collectionView = new CollectionView {
                ItemsLayout = itemsLayout, ItemTemplate = itemTemplate
            };

            var generator = new ItemsSourceGenerator(collectionView);

            var remover  = new ItemRemover(collectionView);
            var adder    = new ItemAdder(collectionView);
            var replacer = new ItemReplacer(collectionView);
            var mover    = new ItemMover(collectionView);

            layout.Children.Add(generator);

            layout.Children.Add(remover);
            Grid.SetRow(remover, 1);

            layout.Children.Add(adder);
            Grid.SetRow(adder, 2);

            layout.Children.Add(replacer);
            Grid.SetRow(replacer, 3);

            layout.Children.Add(mover);
            Grid.SetRow(mover, 4);

            layout.Children.Add(collectionView);
            Grid.SetRow(collectionView, 5);

            Content = layout;

            generator.GenerateObservableCollection();
        }
Beispiel #22
0
        public ObservableMultiItemCollectionViewGallery(ItemsLayoutOrientation orientation = ItemsLayoutOrientation.Vertical,
                                                        bool grid = true, int initialItems = 1000, bool withIndex = false)
        {
            var layout = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Star
                    }
                }
            };

            var itemsLayout = grid
                                ? new GridItemsLayout(3, orientation)
                                : new ListItemsLayout(orientation) as IItemsLayout;

            var itemTemplate = ExampleTemplates.PhotoTemplate();

            var collectionView = new CollectionView {
                ItemsLayout = itemsLayout, ItemTemplate = itemTemplate, AutomationId = "collectionview"
            };

            var generator = new ItemsSourceGenerator(collectionView, initialItems, ItemsSourceType.MultiTestObservableCollection);

            var remover = new MultiItemRemover(collectionView, withIndex);

            var adder    = new MultiItemAdder(collectionView, withIndex);
            var replacer = new MultiItemReplacer(collectionView);
            var mover    = new MultiItemMover(collectionView);

            layout.Children.Add(generator);

            layout.Children.Add(remover);
            Grid.SetRow(remover, 1);

            layout.Children.Add(adder);
            Grid.SetRow(adder, 2);

            layout.Children.Add(replacer);
            Grid.SetRow(replacer, 3);

            layout.Children.Add(mover);
            Grid.SetRow(mover, 4);

            layout.Children.Add(collectionView);
            Grid.SetRow(collectionView, 5);

            Content = layout;

            generator.GenerateItems();
        }