protected virtual void UpdateItemsSource()
        {
            if (ListViewBase == null)
            {
                return;
            }

            // TODO hartez 2018-05-22 12:59 PM Handle grouping

            var itemsSource = Element.ItemsSource;

            if (itemsSource == null)
            {
                if (_collectionViewSource?.Source is INotifyCollectionChanged incc)
                {
                    incc.CollectionChanged -= ItemsChanged;
                }

                _collectionViewSource = null;
                return;
            }

            var itemTemplate = Element.ItemTemplate;

            if (_collectionViewSource != null)
            {
                if (_collectionViewSource.Source is ObservableItemTemplateCollection observableItemTemplateCollection)
                {
                    observableItemTemplateCollection.CleanUp();
                }
            }

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

                if (_collectionViewSource?.Source is INotifyCollectionChanged incc)
                {
                    incc.CollectionChanged += ItemsChanged;
                }
            }
            else
            {
                _collectionViewSource = new CollectionViewSource
                {
                    Source          = itemsSource,
                    IsSourceGrouped = false
                };
            }

            ListViewBase.ItemsSource = _collectionViewSource.View;

            UpdateEmptyViewVisibility();
        }
 protected override CollectionViewSource CreateCollectionViewSource()
 {
     return(new CollectionViewSource
     {
         Source = TemplatedItemSourceFactory.Create(Element.ItemsSource, Element.ItemTemplate, Element,
                                                    GetItemHeight(), GetItemWidth(), GetItemSpacing()),
         IsSourceGrouped = false
     });
 }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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
            });
        }
        protected virtual void UpdateItemsSource()
        {
            if (ListViewBase == null)
            {
                return;
            }

            // TODO hartez 2018-05-22 12:59 PM Handle grouping

            var itemsSource = Element.ItemsSource;

            if (itemsSource == null)
            {
                _collectionViewSource = null;
                return;
            }

            var itemTemplate = Element.ItemTemplate;

            if (itemTemplate != null)
            {
                // The ItemContentControls need the actual data item and the template so they can inflate the template
                // and bind the result to the data item.
                // ItemTemplateEnumerator handles pairing them up for the ItemContentControls to consume

                _collectionViewSource = new CollectionViewSource
                {
                    Source          = TemplatedItemSourceFactory.Create(itemsSource, itemTemplate, Element),
                    IsSourceGrouped = false
                };
            }
            else
            {
                _collectionViewSource = new CollectionViewSource
                {
                    Source          = itemsSource,
                    IsSourceGrouped = false
                };
            }

            ListViewBase.ItemsSource = _collectionViewSource.View;
        }
Exemplo n.º 6
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 void UpdateItemsSource()
        {
            var itemsSource = Element.ItemsSource;

            if (itemsSource == null)
            {
                return;
            }

            var itemTemplate = Element.ItemTemplate;

            if (itemTemplate == null)
            {
                return;
            }

            _collectionViewSource = new CollectionViewSource
            {
                Source          = TemplatedItemSourceFactory.Create(itemsSource, itemTemplate, Element, GetItemHeight(), GetItemWidth(), GetItemSpacing()),
                IsSourceGrouped = false
            };

            ListViewBase.ItemsSource = _collectionViewSource.View;
        }