From 366f1bca274287ca73b9e4648bddcc0831a3e0bd Mon Sep 17 00:00:00 2001 From: Bastian Schmidt Date: Sun, 21 Feb 2021 14:51:38 +0100 Subject: [PATCH] Adding DependencyProperty for ShouldShowOnKeyboardFocus --- .../System/Windows/Controls/tooltip.cs | 23 +++++++++++++++++-- .../Windows/Controls/Ribbon/RibbonToolTip.cs | 17 ++++++-------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/tooltip.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/tooltip.cs index cadbd8d2ef1..22df7f642c4 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/tooltip.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/tooltip.cs @@ -87,11 +87,30 @@ internal bool FromKeyboard } } - internal virtual bool ShouldShowOnKeyboardFocus + /// + /// The DependencyProperty for the ShouldShowOnKeyboardFocus property. + /// Default: true + /// + public static readonly DependencyProperty ShouldShowOnKeyboardFocusProperty = + DependencyProperty.Register( + nameof(ShouldShowOnKeyboardFocus), + typeof(bool), + typeof(ToolTip), + new FrameworkPropertyMetadata(BooleanBoxes.TrueBox)); + + /// + /// Whether or not the tooltip should show on Keyboard focus. + /// + [Bindable(true), Category("Behavior")] + public bool ShouldShowOnKeyboardFocus { get { - return true; + return (bool)GetValue(ShouldShowOnKeyboardFocusProperty); + } + set + { + SetValue(ShouldShowOnKeyboardFocusProperty, BooleanBoxes.Box(value)); } } diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/Ribbon/RibbonToolTip.cs b/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/Ribbon/RibbonToolTip.cs index e4d0234c462..7f334bd7d46 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/Ribbon/RibbonToolTip.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/Ribbon/RibbonToolTip.cs @@ -42,6 +42,13 @@ static RibbonToolTip() DefaultStyleKeyProperty.OverrideMetadata(ownerType, new FrameworkPropertyMetadata(ownerType)); IsOpenProperty.OverrideMetadata(ownerType, new FrameworkPropertyMetadata(new PropertyChangedCallback(OnIsOpenChanged), new CoerceValueCallback(CoerceIsOpen))); PlacementTargetProperty.OverrideMetadata(ownerType, new FrameworkPropertyMetadata(OnPlacementTargetPropertyChanged)); + + // DDVSO 614397: Tooltips should show on Keyboard focus. + // Override from tooltip, we don't want RibbonToolTips to show on Keyboard + // focus to keep this consistent with other Microsoft products. + // If a user needs to bring up a RibbonToolTip this change also + // introduces Ctrl+Shift+F10 as a shortcut for tooltips. + ShouldShowOnKeyboardFocusProperty.OverrideMetadata(ownerType, new FrameworkPropertyMetadata(false)); } /// @@ -128,16 +135,6 @@ private void OnPlacementTargetMouseLeave(object sender, MouseEventArgs e) #region Public Properties - // DDVSO 614397: Tooltips should show on Keyboard focus. - // Override from tooltip, we don't want RibbonToolTips to show on Keyboard - // focus to keep this consistent with other Microsoft products. - // If a user needs to bring up a RibbonToolTip this change also - // introduces Ctrl+Shift+F10 as a shortcut for tooltips. - internal override bool ShouldShowOnKeyboardFocus - { - get { return false; } - } - /// /// Gets or sets the Title property. ///