Represents container of grouped gallery items in GalleryPanel or Gallery
Наследование: System.Windows.Controls.HeaderedItemsControl
Пример #1
0
        private void Refresh()
        {
            // Clear currently used group containers
            // and supply with new generated ones
            foreach (var galleryGroupContainer in this.galleryGroupContainers)
            {
                BindingOperations.ClearAllBindings(galleryGroupContainer);
                this.visualCollection.Remove(galleryGroupContainer);
            }

            this.galleryGroupContainers.Clear();

            // Gets filters
            var filter = this.Filter?.Split(',');

            var dictionary = new Dictionary <string, GalleryGroupContainer>();

            foreach (UIElement item in this.InternalChildren)
            {
                if (item == null)
                {
                    continue;
                }

                // Resolve group name
                string propertyValue = null;

                if (this.GroupByAdvanced != null)
                {
                    propertyValue = this.ItemContainerGenerator == null
                        ? this.GroupByAdvanced(item)
                        : this.GroupByAdvanced(this.ItemContainerGenerator.ItemFromContainerOrContainerContent(item));
                }
                else if (string.IsNullOrEmpty(this.GroupBy) == false)
                {
                    propertyValue = this.ItemContainerGenerator == null
                        ? this.GetPropertyValueAsString(item)
                        : this.GetPropertyValueAsString(this.ItemContainerGenerator.ItemFromContainerOrContainerContent(item));
                }

                if (propertyValue == null)
                {
                    propertyValue = Undefined;
                }

                // Make invisible if it is not in filter (or is not grouped)
                if (this.IsGrouped == false ||
                    (filter != null && filter.Contains(propertyValue) == false))
                {
                    item.Measure(new Size(0, 0));
                    item.Arrange(new Rect(0, 0, 0, 0));
                }

                // Skip if it is not in filter
                if (filter != null &&
                    filter.Contains(propertyValue) == false)
                {
                    continue;
                }

                // To put all items in one group in case of IsGrouped = False
                if (this.IsGrouped == false)
                {
                    propertyValue = Undefined;
                }

                if (dictionary.ContainsKey(propertyValue) == false)
                {
                    var galleryGroupContainer = new GalleryGroupContainer
                    {
                        Header = propertyValue
                    };
                    RibbonControl.Bind(this, galleryGroupContainer, nameof(this.Orientation), GalleryGroupContainer.OrientationProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, nameof(this.ItemWidth), GalleryGroupContainer.ItemWidthProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, nameof(this.ItemHeight), GalleryGroupContainer.ItemHeightProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, nameof(this.MaxItemsInRow), GalleryGroupContainer.MaxItemsInRowProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, nameof(this.MinItemsInRow), GalleryGroupContainer.MinItemsInRowProperty, BindingMode.OneWay);
                    dictionary.Add(propertyValue, galleryGroupContainer);
                    this.galleryGroupContainers.Add(galleryGroupContainer);

                    this.visualCollection.Add(galleryGroupContainer);
                }

                dictionary[propertyValue].Items.Add(new GalleryItemPlaceholder(item));
            }

            if ((this.IsGrouped == false || (this.GroupBy == null && this.GroupByAdvanced == null)) &&
                this.galleryGroupContainers.Count != 0)
            {
                // Make it without headers if there is only one group or if we are not supposed to group
                this.galleryGroupContainers[0].IsHeadered = false;
            }

            this.UpdateMinAndMaxWidth();
            this.InvalidateMeasure();
        }
Пример #2
0
        static void OnMaxMinItemsInRowChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            GalleryGroupContainer galleryGroupContainer = (GalleryGroupContainer)d;

            galleryGroupContainer.maxMinWidthNeedsToBeUpdated = true;
        }
Пример #3
0
        void Refresh()
        {
            // Clear currently used group containers 
            // and supply with new generated ones
            foreach (GalleryGroupContainer galleryGroupContainer in galleryGroupContainers)
            {
                BindingOperations.ClearAllBindings(galleryGroupContainer);
                //RemoveVisualChild(galleryGroupContainer);
                visualCollection.Remove(galleryGroupContainer);
            }
            galleryGroupContainers.Clear();
            
            // Gets filters
            string[] filter = Filter == null ? null : Filter.Split(',');

            Dictionary<string, GalleryGroupContainer> dictionary = new Dictionary<string, GalleryGroupContainer>();
            foreach(UIElement item in InternalChildren)
            {
                if (item == null) continue;

                // Resolve group name
                string propertyValue;
                if (GroupByAdvanced == null)
                {
                    propertyValue = (ItemContainerGenerator == null)
                                        ? GetPropertyValueAsString(item)
                                        : GetPropertyValueAsString(ItemContainerGenerator.ItemFromContainer(item));
                }
                else
                {
                    propertyValue = (ItemContainerGenerator == null)
                                        ? GroupByAdvanced(item)
                                        : GroupByAdvanced(ItemContainerGenerator.ItemFromContainer(item));
                }
                if (propertyValue == null) propertyValue = "Undefined";

                // Make invisible if it is not in filter (or is not grouped)
                if ((!IsGrouped) || (filter != null && !filter.Contains(propertyValue)))
                {
                    item.Measure(new Size(0,0));
                    item.Arrange(new Rect(0,0,0,0));
                }
                // Skip if it is not in filter
                if (filter != null && !filter.Contains(propertyValue)) continue;

                // To put all items in one group in case of IsGrouped = False
                if (!IsGrouped) propertyValue = "Undefined";
                
                if (!dictionary.ContainsKey(propertyValue))
                {
                    GalleryGroupContainer galleryGroupContainer = new GalleryGroupContainer();
                    galleryGroupContainer.Header = propertyValue;
                    RibbonControl.Bind(this, galleryGroupContainer, "GroupStyle", GroupStyleProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "Orientation", GalleryGroupContainer.OrientationProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "ItemWidth", GalleryGroupContainer.ItemWidthProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "ItemHeight", GalleryGroupContainer.ItemHeightProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "MaxItemsInRow", GalleryGroupContainer.MaxItemsInRowProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "MinItemsInRow", GalleryGroupContainer.MinItemsInRowProperty, BindingMode.OneWay);
                    dictionary.Add(propertyValue,galleryGroupContainer);
                    galleryGroupContainers.Add(galleryGroupContainer);
                   
                    visualCollection.Add(galleryGroupContainer);
                }
                dictionary[propertyValue].Items.Add(new GalleryItemPlaceholder(item));
            }

            if (((!IsGrouped) || (GroupBy == null && GroupByAdvanced == null)) && galleryGroupContainers.Count != 0)
            {
                // Make it without headers
                galleryGroupContainers[0].IsHeadered = false;
            }
            
            InvalidateMeasure();
        }
Пример #4
0
        void Refresh()
        {
            // Clear currently used group containers
            // and supply with new generated ones
            foreach (GalleryGroupContainer galleryGroupContainer in galleryGroupContainers)
            {
                BindingOperations.ClearAllBindings(galleryGroupContainer);
                //RemoveVisualChild(galleryGroupContainer);
                visualCollection.Remove(galleryGroupContainer);
            }
            galleryGroupContainers.Clear();

            // Gets filters
            string[] filter = Filter == null ? null : Filter.Split(',');

            Dictionary <string, GalleryGroupContainer> dictionary = new Dictionary <string, GalleryGroupContainer>();

            foreach (UIElement item in InternalChildren)
            {
                if (item == null)
                {
                    continue;
                }

                // Resolve group name
                string propertyValue;
                if (GroupByAdvanced == null)
                {
                    propertyValue = (ItemContainerGenerator == null)
                                        ? GetPropertyValueAsString(item)
                                        : GetPropertyValueAsString(ItemContainerGenerator.ItemFromContainer(item));
                }
                else
                {
                    propertyValue = (ItemContainerGenerator == null)
                                        ? GroupByAdvanced(item)
                                        : GroupByAdvanced(ItemContainerGenerator.ItemFromContainer(item));
                }
                if (propertyValue == null)
                {
                    propertyValue = "Undefined";
                }

                // Make invisible if it is not in filter (or is not grouped)
                if ((!IsGrouped) || (filter != null && !filter.Contains(propertyValue)))
                {
                    item.Measure(new Size(0, 0));
                    item.Arrange(new Rect(0, 0, 0, 0));
                }
                // Skip if it is not in filter
                if (filter != null && !filter.Contains(propertyValue))
                {
                    continue;
                }

                // To put all items in one group in case of IsGrouped = False
                if (!IsGrouped)
                {
                    propertyValue = "Undefined";
                }

                if (!dictionary.ContainsKey(propertyValue))
                {
                    GalleryGroupContainer galleryGroupContainer = new GalleryGroupContainer();
                    galleryGroupContainer.Header = propertyValue;
                    RibbonControl.Bind(this, galleryGroupContainer, "GroupStyle", GroupStyleProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "Orientation", GalleryGroupContainer.OrientationProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "ItemWidth", GalleryGroupContainer.ItemWidthProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "ItemHeight", GalleryGroupContainer.ItemHeightProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "MaxItemsInRow", GalleryGroupContainer.MaxItemsInRowProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "MinItemsInRow", GalleryGroupContainer.MinItemsInRowProperty, BindingMode.OneWay);
                    dictionary.Add(propertyValue, galleryGroupContainer);
                    galleryGroupContainers.Add(galleryGroupContainer);

                    visualCollection.Add(galleryGroupContainer);
                }
                dictionary[propertyValue].Items.Add(new GalleryItemPlaceholder(item));
            }

            if (((!IsGrouped) || (GroupBy == null && GroupByAdvanced == null)) && galleryGroupContainers.Count != 0)
            {
                // Make it without headers
                galleryGroupContainers[0].IsHeadered = false;
            }

            InvalidateMeasure();
        }
Пример #5
0
        private void Refresh()
        {
            if (this.needsRefresh == false)
            {
                return;
            }

            this.needsRefresh = false;

            if (this.itemContainerGeneratorAction == null)
            {
                this.itemContainerGeneratorAction = new ItemContainerGeneratorAction((ItemContainerGenerator)this.ItemContainerGenerator, this.Refresh);
            }

            // Clear currently used group containers 
            // and supply with new generated ones
            foreach (var galleryGroupContainer in this.galleryGroupContainers)
            {
                BindingOperations.ClearAllBindings(galleryGroupContainer);
                this.visualCollection.Remove(galleryGroupContainer);
            }

            this.galleryGroupContainers.Clear();

            // Gets filters
            var filter = this.Filter?.Split(',');

            var dictionary = new Dictionary<string, GalleryGroupContainer>();

            foreach (UIElement item in this.InternalChildren)
            {
                if (item == null)
                {
                    continue;
                }

                // Resolve group name
                string propertyValue = null;

                if (this.GroupByAdvanced == null)
                {
                    propertyValue = this.ItemContainerGenerator == null
                                        ? this.GetPropertyValueAsString(item)
                                        : this.GetPropertyValueAsString(this.ItemContainerGenerator.GetItemContainerGeneratorForPanel(this).ItemFromContainer(item));
                }
                else
                {
                    propertyValue = this.ItemContainerGenerator == null
                                        ? this.GroupByAdvanced(item)
                                        : this.GroupByAdvanced(this.ItemContainerGenerator.GetItemContainerGeneratorForPanel(this).ItemFromContainer(item));
                }

                if (propertyValue == null)
                {
                    propertyValue = "Undefined";
                }

                // Make invisible if it is not in filter
                if (this.IsGrouped
                    && filter != null
                    && filter.Contains(propertyValue) == false)
                {
                    item.Visibility = Visibility.Collapsed;
                    continue;
                }

                // Make all not filtered items visible
                item.Visibility = Visibility.Visible;

                // To put all items in one group in case of IsGrouped = False
                if (this.IsGrouped == false)
                {
                    propertyValue = "Undefined";
                }

                if (dictionary.ContainsKey(propertyValue) == false)
                {
                    var galleryGroupContainer = new GalleryGroupContainer
                    {
                        Header = propertyValue
                    };

                    RibbonControl.Bind(this, galleryGroupContainer, "GroupStyle", GroupStyleProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "Orientation", GalleryGroupContainer.OrientationProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "ItemWidth", GalleryGroupContainer.ItemWidthProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "ItemHeight", GalleryGroupContainer.ItemHeightProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "MaxItemsInRow", GalleryGroupContainer.MaxItemsInRowProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "MinItemsInRow", GalleryGroupContainer.MinItemsInRowProperty, BindingMode.OneWay);
                    dictionary.Add(propertyValue, galleryGroupContainer);
                    this.galleryGroupContainers.Add(galleryGroupContainer);

                    this.visualCollection.Add(galleryGroupContainer);
                }

                dictionary[propertyValue].Items.Add(new GalleryItemPlaceholder(item));
            }

            if ((this.IsGrouped == false || (this.GroupBy == null && this.GroupByAdvanced == null))
                && this.galleryGroupContainers.Count != 0)
            {
                // Make it without headers
                this.galleryGroupContainers[0].IsHeadered = false;
            }

            this.InvalidateMeasure();
        }
Пример #6
0
        private void Refresh()
        {
            if (this.needsRefresh == false)
            {
                return;
            }

            this.needsRefresh = false;

            if (this.itemContainerGeneratorAction == null)
            {
                this.itemContainerGeneratorAction = new ItemContainerGeneratorAction((ItemContainerGenerator)this.ItemContainerGenerator, this.Refresh);
            }

            // Clear currently used group containers
            // and supply with new generated ones
            foreach (var galleryGroupContainer in this.galleryGroupContainers)
            {
                BindingOperations.ClearAllBindings(galleryGroupContainer);
                this.visualCollection.Remove(galleryGroupContainer);
            }

            this.galleryGroupContainers.Clear();

            // Gets filters
            var filter = this.Filter?.Split(',');

            var dictionary = new Dictionary <string, GalleryGroupContainer>();

            foreach (UIElement item in this.InternalChildren)
            {
                if (item == null)
                {
                    continue;
                }

                // Resolve group name
                string propertyValue = null;

                if (this.GroupByAdvanced == null)
                {
                    propertyValue = this.ItemContainerGenerator == null
                                        ? this.GetPropertyValueAsString(item)
                                        : this.GetPropertyValueAsString(this.ItemContainerGenerator.GetItemContainerGeneratorForPanel(this).ItemFromContainer(item));
                }
                else
                {
                    propertyValue = this.ItemContainerGenerator == null
                                        ? this.GroupByAdvanced(item)
                                        : this.GroupByAdvanced(this.ItemContainerGenerator.GetItemContainerGeneratorForPanel(this).ItemFromContainer(item));
                }

                if (propertyValue == null)
                {
                    propertyValue = "Undefined";
                }

                // Make invisible if it is not in filter
                if (this.IsGrouped &&
                    filter != null &&
                    filter.Contains(propertyValue) == false)
                {
                    item.Visibility = Visibility.Collapsed;
                    continue;
                }

                // Make all not filtered items visible
                item.Visibility = Visibility.Visible;

                // To put all items in one group in case of IsGrouped = False
                if (this.IsGrouped == false)
                {
                    propertyValue = "Undefined";
                }

                if (dictionary.ContainsKey(propertyValue) == false)
                {
                    var galleryGroupContainer = new GalleryGroupContainer
                    {
                        Header = propertyValue
                    };

                    RibbonControl.Bind(this, galleryGroupContainer, "GroupStyle", GroupStyleProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "Orientation", GalleryGroupContainer.OrientationProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "ItemWidth", GalleryGroupContainer.ItemWidthProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "ItemHeight", GalleryGroupContainer.ItemHeightProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "MaxItemsInRow", GalleryGroupContainer.MaxItemsInRowProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "MinItemsInRow", GalleryGroupContainer.MinItemsInRowProperty, BindingMode.OneWay);
                    dictionary.Add(propertyValue, galleryGroupContainer);
                    this.galleryGroupContainers.Add(galleryGroupContainer);

                    this.visualCollection.Add(galleryGroupContainer);
                }

                dictionary[propertyValue].Items.Add(new GalleryItemPlaceholder(item));
            }

            if ((this.IsGrouped == false || (this.GroupBy == null && this.GroupByAdvanced == null)) &&
                this.galleryGroupContainers.Count != 0)
            {
                // Make it without headers
                this.galleryGroupContainers[0].IsHeadered = false;
            }

            this.InvalidateMeasure();
        }