private static object CoerceDefaultControlSizeDefinition(DependencyObject d, object baseValue) { if (baseValue == null) { RibbonControlGroup controlGroup = (RibbonControlGroup)d; RibbonImageSize imageSize = RibbonImageSize.Collapsed; bool isLabelVisible = false; int itemCount = controlGroup.Items.Count; bool childFound = false; // Get the largest ControlSizeDefinition variant for all // the child controls and construct a union ControlSizeDefinition. for (int i = 0; i < itemCount; i++) { RibbonControl ribbonControl = controlGroup.ItemContainerGenerator.ContainerFromIndex(i) as RibbonControl; if (ribbonControl != null && ribbonControl.Visibility != Visibility.Collapsed) { UIElement contentChild = ribbonControl.ContentChild; if (contentChild != null && contentChild.Visibility != Visibility.Collapsed) { RibbonControlSizeDefinition currentLargeCsd = RibbonControlService.GetDefaultControlSizeDefinition(contentChild); if (currentLargeCsd == null) { contentChild.CoerceValue(RibbonControlService.DefaultControlSizeDefinitionProperty); currentLargeCsd = RibbonControlService.GetDefaultControlSizeDefinition(contentChild); } if (currentLargeCsd != null) { childFound = true; if (imageSize == RibbonImageSize.Collapsed) { imageSize = currentLargeCsd.ImageSize; } else if (currentLargeCsd.ImageSize == RibbonImageSize.Large) { imageSize = RibbonImageSize.Large; } isLabelVisible |= currentLargeCsd.IsLabelVisible; if (isLabelVisible && imageSize == RibbonImageSize.Large) { break; } } } } } if (childFound) { return(RibbonControlSizeDefinition.GetFrozenControlSizeDefinition(imageSize, isLabelVisible)); } } return(baseValue); }
private static void UpdateDefaultControlSizeDefinition(DependencyObject d) { d.CoerceValue(DefaultControlSizeDefinitionProperty); // If the element belongs to a ControlGroup, then // coerce DefaultControlSizeDefinition for the ControlGroup too. if (RibbonControlService.GetIsInControlGroup(d)) { RibbonControlGroup controlGroup = TreeHelper.FindVisualAncestor <RibbonControlGroup>(d); if (controlGroup != null) { controlGroup.CoerceValue(DefaultControlSizeDefinitionProperty); } } }
public RibbonControlGroupAutomationPeer(RibbonControlGroup owner) : base(owner) { }
private static void OnControlSizeDefinitionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { RibbonControlGroup rcg = (RibbonControlGroup)d; rcg.TransferPseudoInheritedProperties(); }