示例#1
0
        // InRibbonGalleryMode where the gallery is shown within Ribbon via InRibbonGallery and Arrange
        // becomes responsibility of InRibbonGalleryModeArrangeOverride.
        private Size InRibbonGalleryModeArrangeOverride(Size finalSize)
        {
            UIElementCollection children = this.Children;
            Rect rcChild = new Rect(finalSize);

            //
            // Seed scroll offset into rcChild.
            //
            if (IsScrolling)
            {
                rcChild.X = -1.0 * _scrollData._offset.X;
                rcChild.Y = -1.0 * _scrollData._offset.Y;
            }

            // Arrange and Position Children. over each other as the items being arranged in child
            // in a way to respect the offset of where previous category children are ending.
            // It's merged wrapping.
            for (int i = 0, count = children.Count; i < count; ++i)
            {
                RibbonGalleryCategory child = children[i] as RibbonGalleryCategory;

                if (child == null ||
                    child.Visibility == Visibility.Collapsed)
                {
                    continue;
                }

                rcChild.Width = Math.Max(finalSize.Width, child.DesiredSize.Width);
                child.Arrange(rcChild);
            }

            // Refresh the IsEnabled state of the InRibbonGallery's LineUp & LineDown buttons.
            RibbonGallery gallery = Gallery;

            if (gallery != null)
            {
                InRibbonGallery irg = gallery.ParentInRibbonGallery;
                if (irg != null &&
                    irg.IsInInRibbonMode)
                {
                    irg.CoerceValue(InRibbonGallery.CanLineUpProperty);
                    irg.CoerceValue(InRibbonGallery.CanLineDownProperty);
                }
            }

            return(DesiredSize);
        }
示例#2
0
        // Updates Width and other layout properties in the Visual tree from RibbonControl to InRibbonGallery wherever needed
        // when attains In Ribbon mode.
        private static void OnControlSizeDefinitionChanged(DependencyObject d, DependencyPropertyChangedEventArgs args)
        {
            InRibbonGallery me = (InRibbonGallery)d;

            me.CoerceValue(IsCollapsedProperty);
            if (me.IsInInRibbonMode)
            {
                if (me._ribbonControl == null)
                {
                    me._ribbonControl = TreeHelper.FindAncestor(me, delegate(DependencyObject element)
                    {
                        RibbonControl rc = (element as RibbonControl);
                        if (rc != null)
                        {
                            return(me == rc.ContentChild);
                        }

                        return(false);
                    }) as RibbonControl;
                }
            }

            me.UpdateInRibbonGalleryModeProperties();
        }