GroupTemplateContext CreateGroupTemplateContext(object group)
        {
            var groupHeaderTemplateContext = _groupHeaderTemplate != null
                                        ? new ItemTemplateContext(_groupHeaderTemplate, group, _container) : null;

            var groupFooterTemplateContext = _groupFooterTemplate != null
                                ? new GroupFooterItemTemplateContext(_groupFooterTemplate, group, _container) : null;

            // This is where we'll eventually look at GroupItemPropertyName
            var groupItemsList = TemplatedItemSourceFactory.Create(group as IEnumerable, _itemTemplate, _container);

            return(new GroupTemplateContext(groupHeaderTemplateContext, groupFooterTemplateContext, groupItemsList));
        }
        protected override CollectionViewSource CreateCollectionViewSource()
        {
            var collectionViewSource = TemplatedItemSourceFactory.Create(Element.ItemsSource, Element.ItemTemplate, Element,
                                                                         GetItemHeight(), GetItemWidth(), GetItemSpacing());

            if (collectionViewSource is ObservableItemTemplateCollection observableItemsSource)
            {
                observableItemsSource.CollectionChanged += CollectionItemsSourceChanged;
            }

            return(new CollectionViewSource
            {
                Source = collectionViewSource,
                IsSourceGrouped = false
            });
        }
Exemple #3
0
        protected virtual CollectionViewSource CreateCollectionViewSource()
        {
            var itemsSource  = Element.ItemsSource;
            var itemTemplate = Element.ItemTemplate;

            if (itemTemplate != null)
            {
                return(new CollectionViewSource
                {
                    Source = TemplatedItemSourceFactory.Create(itemsSource, itemTemplate, Element),
                    IsSourceGrouped = false
                });
            }

            return(new CollectionViewSource
            {
                Source = itemsSource,
                IsSourceGrouped = false
            });
        }
        protected override CollectionViewSource CreateCollectionViewSource()
        {
            if (ItemsView != null && ItemsView.IsGrouped)
            {
                var itemTemplate = Element.ItemTemplate;
                var itemsSource  = Element.ItemsSource;

                return(new CollectionViewSource
                {
                    Source = TemplatedItemSourceFactory.CreateGrouped(itemsSource, itemTemplate,
                                                                      ItemsView.GroupHeaderTemplate, ItemsView.GroupFooterTemplate, Element),
                    IsSourceGrouped = true,
                    ItemsPath = new Microsoft.UI.Xaml.PropertyPath(nameof(GroupTemplateContext.Items))
                });
            }
            else
            {
                return(base.CreateCollectionViewSource());
            }
        }