/// <summary> /// Notify corresponding KeyTipAdorner regarding size change. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void OnSizeChanged(object sender, SizeChangedEventArgs e) { KeyTipControl keyTipControl = sender as KeyTipControl; if (keyTipControl != null && keyTipControl.KeyTipAdorner != null) { keyTipControl.KeyTipAdorner.OnKeyTipControlSizeChanged(e); } }
void LinkKeyTipControl() { if (Element == null || KeyTipControl == null) { return; } KeyTipControl.Text = KeyTipService.GetKeyTip(Element).ToUpper(KeyTipService.GetCultureForElement(Element)); KeyTipControl.IsEnabled = (bool)Element.GetValue(UIElement.IsEnabledProperty); var keyTipStyle = KeyTipService.GetKeyTipStyle(Element); KeyTipControl.Style = keyTipStyle; KeyTipControl.RenderTransform = _keyTipTransform; bool clearCustomProperties = true; if (keyTipStyle == null) { var ribbon = (Menu.MenuRibbon)(PlacementTarget ?? Element).VisualHierarchy().FirstOrDefault(x => x is Menu.MenuRibbon); if (ribbon != null) { // Use Ribbon properties if the owner element belongs to a Ribbon. keyTipStyle = KeyTipService.GetKeyTipStyle(ribbon); if (keyTipStyle != null) { _keyTipControl.Style = keyTipStyle; } else { clearCustomProperties = false; _keyTipControl.Background = ribbon.Background; _keyTipControl.BorderBrush = ribbon.BorderBrush; _keyTipControl.Foreground = ribbon.Foreground; } } } if (clearCustomProperties) { KeyTipControl.ClearValue(Control.BackgroundProperty); KeyTipControl.ClearValue(Control.BorderBrushProperty); KeyTipControl.ClearValue(Control.ForegroundProperty); } EnsureTransform(); }