Represents panel for Gallery, InRibbonGallery, ComboBox with grouping and filtering capabilities
Inheritance: System.Windows.Controls.VirtualizingStackPanel
Beispiel #1
0
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or internal processes call <see cref="M:System.Windows.FrameworkElement.ApplyTemplate"/>.
        /// </summary>
        public override void OnApplyTemplate()
        {
            if (popup != null) popup.CustomPopupPlacementCallback -= CustomPopupPlacementMethod;
            popup = GetTemplateChild("PART_Popup") as Popup;
            if (popup != null)
            {
                popup.Placement = PlacementMode.Custom;
                popup.CustomPopupPlacementCallback += CustomPopupPlacementMethod;
            }


            editableTextBox = GetTemplateChild("PART_EditableTextBox") as System.Windows.Controls.TextBox;

            if (resizeVerticalThumb != null)
            {
                resizeVerticalThumb.DragDelta -= OnResizeVerticalDelta;
            }
            resizeVerticalThumb = GetTemplateChild("PART_ResizeVerticalThumb") as Thumb;
            if (resizeVerticalThumb != null)
            {
                resizeVerticalThumb.DragDelta += OnResizeVerticalDelta;
            }

            if (resizeBothThumb != null)
            {
                resizeBothThumb.DragDelta -= OnResizeBothDelta;
            }
            resizeBothThumb = GetTemplateChild("PART_ResizeBothThumb") as Thumb;
            if (resizeBothThumb != null)
            {
                resizeBothThumb.DragDelta += OnResizeBothDelta;
            }

            menuPanel = GetTemplateChild("PART_MenuPanel") as Panel;

            snappedImage = GetTemplateChild("PART_SelectedImage") as Image;
            contentSite = GetTemplateChild("PART_ContentSite") as ContentPresenter;

            if (contentBorder != null) contentBorder.PreviewMouseDown -= OnContentBorderPreviewMouseDown;
            contentBorder = GetTemplateChild("PART_ContentBorder") as Border;
            if (contentBorder != null) contentBorder.PreviewMouseDown += OnContentBorderPreviewMouseDown;

            galleryPanel = GetTemplateChild("PART_GalleryPanel") as GalleryPanel;
            scrollViewer = GetTemplateChild("PART_ScrollViewer") as ScrollViewer;

            dropDownBorder = GetTemplateChild("PART_DropDownBorder") as Border;

            base.OnApplyTemplate();
        }
Beispiel #2
0
        /// <summary>
        ///     When overridden in a derived class, is invoked whenever application code or internal processes call
        ///     <see cref="M:System.Windows.FrameworkElement.ApplyTemplate" />.
        /// </summary>
        public override void OnApplyTemplate()
        {
            this.DropDownPopup = this.GetTemplateChild("PART_Popup") as Popup;

            if (this.resizeVerticalThumb != null)
            {
                this.resizeVerticalThumb.DragDelta -= this.OnResizeVerticalDelta;
            }
            this.resizeVerticalThumb = this.GetTemplateChild("PART_ResizeVerticalThumb") as Thumb;
            if (this.resizeVerticalThumb != null)
            {
                this.resizeVerticalThumb.DragDelta += this.OnResizeVerticalDelta;
            }

            if (this.resizeBothThumb != null)
            {
                this.resizeBothThumb.DragDelta -= this.OnResizeBothDelta;
            }
            this.resizeBothThumb = this.GetTemplateChild("PART_ResizeBothThumb") as Thumb;
            if (this.resizeBothThumb != null)
            {
                this.resizeBothThumb.DragDelta += this.OnResizeBothDelta;
            }

            this.menuPanel = this.GetTemplateChild("PART_MenuPanel") as Panel;

            this.snappedImage = this.GetTemplateChild("PART_SelectedImage") as Image;
            this.contentSite = this.GetTemplateChild("PART_ContentSite") as ContentPresenter;

            if (this.contentBorder != null) this.contentBorder.PreviewMouseDown -= this.OnContentBorderPreviewMouseDown;
            this.contentBorder = this.GetTemplateChild("PART_ContentBorder") as Border;
            if (this.contentBorder != null) this.contentBorder.PreviewMouseDown += this.OnContentBorderPreviewMouseDown;

            this.galleryPanel = this.GetTemplateChild("PART_GalleryPanel") as GalleryPanel;
            this.scrollViewer = this.GetTemplateChild("PART_ScrollViewer") as ScrollViewer;

            this.dropDownBorder = this.GetTemplateChild("PART_DropDownBorder") as Border;

            base.OnApplyTemplate();
        }
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application 
        /// code or internal processes call ApplyTemplate
        /// </summary>
        public override void OnApplyTemplate()
        {
            this.layoutRoot = this.GetTemplateChild("PART_LayoutRoot") as FrameworkElement;

            if (this.expandButton != null)
                this.expandButton.Click -= this.OnExpandClick;
            this.expandButton = this.GetTemplateChild("PART_ExpandButton") as ToggleButton;
            if (this.expandButton != null)
                this.expandButton.Click += this.OnExpandClick;

            if (this.dropDownButton != null)
                this.dropDownButton.Click -= this.OnDropDownClick;
            this.dropDownButton = this.GetTemplateChild("PART_DropDownButton") as ToggleButton;
            if (this.dropDownButton != null)
                this.dropDownButton.Click += this.OnDropDownClick;

            if (this.popup != null)
            {
                this.popup.Opened -= this.OnDropDownOpened;
                this.popup.Closed -= this.OnDropDownClosed;

                this.popup.PreviewMouseLeftButtonUp -= this.OnPopupPreviewMouseUp;
                this.popup.PreviewMouseLeftButtonDown -= this.OnPopupPreviewMouseDown;
            }

            this.popup = this.GetTemplateChild("PART_Popup") as Popup;

            if (this.popup != null)
            {
                this.popup.Opened += this.OnDropDownOpened;
                this.popup.Closed += this.OnDropDownClosed;

                this.popup.PreviewMouseLeftButtonUp += this.OnPopupPreviewMouseUp;
                this.popup.PreviewMouseLeftButtonDown += this.OnPopupPreviewMouseDown;

                KeyboardNavigation.SetControlTabNavigation(this.popup, KeyboardNavigationMode.Cycle);
                KeyboardNavigation.SetDirectionalNavigation(this.popup, KeyboardNavigationMode.Cycle);
                KeyboardNavigation.SetTabNavigation(this.popup, KeyboardNavigationMode.Cycle);
            }

            if (this.resizeVerticalThumb != null)
            {
                this.resizeVerticalThumb.DragDelta -= this.OnResizeVerticalDelta;
            }
            this.resizeVerticalThumb = this.GetTemplateChild("PART_ResizeVerticalThumb") as Thumb;
            if (this.resizeVerticalThumb != null)
            {
                this.resizeVerticalThumb.DragDelta += this.OnResizeVerticalDelta;
            }

            if (this.resizeBothThumb != null)
            {
                this.resizeBothThumb.DragDelta -= this.OnResizeBothDelta;
            }
            this.resizeBothThumb = this.GetTemplateChild("PART_ResizeBothThumb") as Thumb;
            if (this.resizeBothThumb != null)
            {
                this.resizeBothThumb.DragDelta += this.OnResizeBothDelta;
            }

            this.menuPanel = this.GetTemplateChild("PART_MenuPanel") as Panel;

            if (this.groupsMenuButton != null)
                this.groupsMenuButton.Items.Clear();
            this.groupsMenuButton = this.GetTemplateChild("PART_FilterDropDownButton") as DropDownButton;
            if (this.groupsMenuButton != null)
            {
                for (int i = 0; i < this.Filters.Count; i++)
                {
                    MenuItem item = new MenuItem();
                    item.Header = this.Filters[i].Title;
                    item.Tag = this.Filters[i];
                    item.IsDefinitive = false;
                    if (this.Filters[i] == this.SelectedFilter) item.IsChecked = true;
                    item.Click += this.OnFilterMenuItemClick;
                    this.groupsMenuButton.Items.Add(item);
                }
            }

			this.galleryPanel = this.GetTemplateChild("PART_GalleryPanel") as GalleryPanel;

            if (this.galleryPanel != null)
            {
				this.galleryPanel.MinItemsInRow = this.MaxItemsInRow;
				this.galleryPanel.MaxItemsInRow = this.MaxItemsInRow;
            }

            this.snappedImage = this.GetTemplateChild("PART_FakeImage") as Image;

            this.controlPresenter = this.GetTemplateChild("PART_ContentPresenter") as ContentControl;
            this.popupControlPresenter = this.GetTemplateChild("PART_PopupContentPresenter") as ContentControl;

            this.scrollViewer = this.GetTemplateChild("PART_ScrollViewer") as ScrollViewer;
        }
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application 
        /// code or internal processes call ApplyTemplate
        /// </summary>
        public override void OnApplyTemplate()
        {
            if (expandButton != null) expandButton.Click -= OnExpandClick;
            expandButton = GetTemplateChild("PART_ExpandButton") as ToggleButton;
            if (expandButton != null) expandButton.Click += OnExpandClick;

            if (dropDownButton != null) dropDownButton.Click -= OnDropDownClick;
            dropDownButton = GetTemplateChild("PART_DropDownButton") as ToggleButton;
            if (dropDownButton != null) dropDownButton.Click += OnDropDownClick;

            layoutRoot = GetTemplateChild("PART_LayoutRoot") as Panel;

            if (popup != null)
            {
                popup.Opened -= OnDropDownOpened;
                popup.Closed -= OnDropDownClosed;

                popup.PreviewMouseLeftButtonUp -= OnPopupPreviewMouseUp;
                popup.PreviewMouseLeftButtonDown -= OnPopupPreviewMouseDown;
            }

            popup = GetTemplateChild("PART_Popup") as Popup;

            if (popup != null)
            {
                popup.Opened += OnDropDownOpened;
                popup.Closed += OnDropDownClosed;

                popup.PreviewMouseLeftButtonUp += OnPopupPreviewMouseUp;
                popup.PreviewMouseLeftButtonDown += OnPopupPreviewMouseDown;

                KeyboardNavigation.SetControlTabNavigation(popup, KeyboardNavigationMode.Cycle);
                KeyboardNavigation.SetDirectionalNavigation(popup, KeyboardNavigationMode.Cycle);
                KeyboardNavigation.SetTabNavigation(popup, KeyboardNavigationMode.Cycle);
            }

            if (resizeVerticalThumb != null)
            {
                resizeVerticalThumb.DragDelta -= OnResizeVerticalDelta;
            }
            resizeVerticalThumb = GetTemplateChild("PART_ResizeVerticalThumb") as Thumb;
            if (resizeVerticalThumb != null)
            {
                resizeVerticalThumb.DragDelta += OnResizeVerticalDelta;
            }

            if (resizeBothThumb != null)
            {
                resizeBothThumb.DragDelta -= OnResizeBothDelta;
            }
            resizeBothThumb = GetTemplateChild("PART_ResizeBothThumb") as Thumb;
            if (resizeBothThumb != null)
            {
                resizeBothThumb.DragDelta += OnResizeBothDelta;
            }

            menuPanel = GetTemplateChild("PART_MenuPanel") as Panel;

            if (groupsMenuButton != null) groupsMenuButton.Items.Clear();
            groupsMenuButton = GetTemplateChild("PART_FilterDropDownButton") as DropDownButton;
            if (groupsMenuButton != null)
            {
                for (int i = 0; i < Filters.Count; i++)
                {
                    MenuItem item = new MenuItem();
                    item.Header = Filters[i].Title;
                    item.Tag = Filters[i];
                    item.IsDefinitive = false;
                    if (Filters[i] == SelectedFilter) item.IsChecked = true;
                    item.Click += OnFilterMenuItemClick;
                    groupsMenuButton.Items.Add(item);
                }
            }

            galleryPanel = GetTemplateChild("PART_GalleryPanel") as GalleryPanel;
            if (galleryPanel != null)
            {
                galleryPanel.MinItemsInRow = MaxItemsInRow;
                galleryPanel.MaxItemsInRow = MaxItemsInRow;
            }

            snappedImage = GetTemplateChild("PART_FakeImage") as Image;

            controlPresenter = GetTemplateChild("PART_ContentPresenter") as ContentControl;
            popupControlPresenter = GetTemplateChild("PART_PopupContentPresenter") as ContentControl;

            scrollViewer = GetTemplateChild("PART_ScrollViewer") as ScrollViewer;
        }
Beispiel #5
0
        static void OnGroupByChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            GalleryPanel galleryPanel = (GalleryPanel)d;

            galleryPanel.Invalidate();
        }
Beispiel #6
0
        static void OnItemContainerGeneratorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            GalleryPanel galleryPanel = (GalleryPanel)d;

            galleryPanel.Invalidate();
        }
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application 
        /// code or internal processes call ApplyTemplate
        /// </summary>
        public override void OnApplyTemplate()
        {
            this.layoutRoot = this.GetTemplateChild("PART_LayoutRoot") as FrameworkElement;

            if (this.expandButton != null)
            {
                this.expandButton.Click -= this.OnExpandClick;
            }

            this.expandButton = this.GetTemplateChild("PART_ExpandButton") as ToggleButton;

            if (this.expandButton != null)
            {
                this.expandButton.Click += this.OnExpandClick;
            }

            if (this.dropDownButton != null)
            {
                this.dropDownButton.Click -= this.OnDropDownClick;
            }

            this.dropDownButton = this.GetTemplateChild("PART_DropDownButton") as ToggleButton;

            if (this.dropDownButton != null)
            {
                this.dropDownButton.Click += this.OnDropDownClick;
            }

            if (this.popup != null)
            {
                this.popup.Opened -= this.OnDropDownOpened;
                this.popup.Closed -= this.OnDropDownClosed;

                this.popup.PreviewMouseLeftButtonUp -= this.OnPopupPreviewMouseUp;
                this.popup.PreviewMouseLeftButtonDown -= this.OnPopupPreviewMouseDown;
            }

            this.popup = this.GetTemplateChild("PART_Popup") as Popup;

            if (this.popup != null)
            {
                this.popup.Opened += this.OnDropDownOpened;
                this.popup.Closed += this.OnDropDownClosed;

                this.popup.PreviewMouseLeftButtonUp += this.OnPopupPreviewMouseUp;
                this.popup.PreviewMouseLeftButtonDown += this.OnPopupPreviewMouseDown;

                KeyboardNavigation.SetControlTabNavigation(this.popup, KeyboardNavigationMode.Cycle);
                KeyboardNavigation.SetDirectionalNavigation(this.popup, KeyboardNavigationMode.Cycle);
                KeyboardNavigation.SetTabNavigation(this.popup, KeyboardNavigationMode.Cycle);
            }

            if (this.resizeVerticalThumb != null)
            {
                this.resizeVerticalThumb.DragDelta -= this.OnResizeVerticalDelta;
            }

            this.resizeVerticalThumb = this.GetTemplateChild("PART_ResizeVerticalThumb") as Thumb;

            if (this.resizeVerticalThumb != null)
            {
                this.resizeVerticalThumb.DragDelta += this.OnResizeVerticalDelta;
            }

            if (this.resizeBothThumb != null)
            {
                this.resizeBothThumb.DragDelta -= this.OnResizeBothDelta;
            }

            this.resizeBothThumb = this.GetTemplateChild("PART_ResizeBothThumb") as Thumb;

            if (this.resizeBothThumb != null)
            {
                this.resizeBothThumb.DragDelta += this.OnResizeBothDelta;
            }

            this.menuPanel = this.GetTemplateChild("PART_MenuPanel") as Panel;

            this.groupsMenuButton?.Items.Clear();

            this.groupsMenuButton = this.GetTemplateChild("PART_FilterDropDownButton") as DropDownButton;

            if (this.groupsMenuButton != null)
            {
                foreach (var currentFilter in this.Filters)
                {
                    var item = new MenuItem
                    {
                        Header = currentFilter.Title,
                        Tag = currentFilter,
                        IsDefinitive = false
                    };

                    if (ReferenceEquals(currentFilter, this.SelectedFilter))
                    {
                        item.IsChecked = true;
                    }

                    item.Click += this.OnFilterMenuItemClick;
                    this.groupsMenuButton.Items.Add(item);
                }
            }

            this.galleryPanel = this.GetTemplateChild("PART_GalleryPanel") as GalleryPanel;

            if (this.galleryPanel != null)
            {
                this.galleryPanel.MinItemsInRow = this.MinItemsInRow;
                this.galleryPanel.MaxItemsInRow = this.MaxItemsInRow;
                this.galleryPanel.UpdateMinAndMaxWidth();
            }

            this.snappedImage = this.GetTemplateChild("PART_FakeImage") as Image;

            this.controlPresenter = this.GetTemplateChild("PART_ContentPresenter") as ContentControl;

            this.popupControlPresenter = this.GetTemplateChild("PART_PopupContentPresenter") as ContentControl;

            this.scrollViewer = this.GetTemplateChild("PART_ScrollViewer") as ScrollViewer;

            this.RunInDispatcherAsync(this.ForceContentRefreshToFixLayout, DispatcherPriority.ContextIdle);
        }