.NET Framework 4.8 : Invoking ToolTip on Tab Key Press Or Focus Using a Keyboard

If you work with Windows based applications using the .NET framework, tooltips would be a common area you have worked in. Normally, the tooltip gets invoked when you have a mouse pointer hover over the control for which you have configured it.

With .NET framework 4.8, Microsoft has come up with a subtle change that goes a long way in determining how accessible your application is as far as tooltips are concerned.

You can set an application level switch that would let the .NET framework know you need to override the existing ToolTip behavior.  This is possible through the AppContext class which enables the developers of APIs to provide new behavior and retain the old behavior in newer versions of their API libraries using switches.

The consumers of these libraries can override these switches and select old/new behavior.

This can be done in the app.config file of your application or by using AppContext.SetSwtich(String, Boolean).

Let us take an example of a simple Windows Forms application having a button with a tooltip :

In earlier versions of .NET Framework this was only possible through mouse hover.

With .NET Framework 4.8 you can override a set of application switches and achieve this when the control is brought into focus using keyboard.

We can define this in our app.config file :

<?xml version="1.0" encoding="utf-8"?>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
    <!-- AppContextSwitchOverrides values are in the form of 'key1=true|false;key2=true|false  -->
    <!-- Please note that disabling Switch.UseLegacyAccessibilityFeatures, Switch.UseLegacyAccessibilityFeatures.2 and Switch.UseLegacyAccessibilityFeatures.3 is required to disable Switch.System.Windows.Forms.UseLegacyToolTipDisplay -->
    <AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false;Switch.UseLegacyAccessibilityFeatures.2=false;Switch.UseLegacyAccessibilityFeatures.3=false;Switch.System.Windows.Forms.UseLegacyToolTipDisplay=false"/>

That is all. Once you bring up your application after the above change, you can get the tooltip to show using keyboard focus.

One thought on “.NET Framework 4.8 : Invoking ToolTip on Tab Key Press Or Focus Using a Keyboard

  • Hello,

    I do not know if you will be able to help me, but I have a problem with the tooltips in my WPF application since I upgraded to .NET 4.8… The tooltips suddenly started to show on Tab navigation instead of just the mouse… but I didn’t add the switch like you explained in this post…. Do you know how to turn that off? I tried to invert the switch in your post (set everything to false), but it didn’t work…

    Any help would be much appreciated.
    Thanks in advance!


Leave a Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.