wpf-notifyicon icon indicating copy to clipboard operation
wpf-notifyicon copied to clipboard

tray icon tooltips broken in windows 11

Open Samuel12321 opened this issue 3 years ago • 24 comments

just displays tooltip

Samuel12321 avatar Sep 19 '21 08:09 Samuel12321

Hey @Samuel12321, do you have more information or is that all? What do you mean with "just displays tooltip"? In what scenario is the tray icon running, did you try the samples?

Best wishes, Robin

Lakritzator avatar Sep 19 '21 19:09 Lakritzator

Hi @Lakritzator , Thanks for the quick response. I'm one of the devs for ModernFlyouts, we have been using Hardcodet WPF NotifyIcon to display a tray icon. When the user hovers over it it is supposed to display a tooltip saying "ModernFlyouts" as seen in the image below. image This works well on all versions of Windows 10, however if the app is installed on Windows 11, it just displays "tooltip", as seen in the image below. image We have multiple reports confirming this occurs on all versions of Windows 11. The source code is below.

using Hardcodet.Wpf.TaskbarNotification;
using ModernFlyouts.Helpers;
using ModernFlyouts.Utilities;
using ModernWpf;
using ModernWpf.Controls;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;

namespace ModernFlyouts.UI
{
    internal class TrayIconManager
    {
        #region Properties

        public static TaskbarIcon TaskbarIcon { get; private set; }

        public static ContextMenu TaskbarIconContextMenu { get; private set; }

        public static ToolTip TaskbarIconToolTip { get; private set; }

        #endregion

        public static void SetupTrayIcon()
        {
            var settingsItem = new MenuItem()
            {
                Header = Properties.Strings.SettingsItem,
                ToolTip = Properties.Strings.SettingsItemDescription,
                Icon = new FontIcon() { Glyph = CommonGlyphs.Settings },
                Command = CommonCommands.OpenSettingsWindowCommand
            };

            var exitItem = new MenuItem()
            {
                Header = Properties.Strings.ExitItem,
                ToolTip = Properties.Strings.ExitItemDescription,
                Icon = new FontIcon() { Glyph = CommonGlyphs.PowerButton },
                Command = CommonCommands.ExitAppCommand
            };

            TaskbarIconContextMenu = new ContextMenu()
            {
                Items = { settingsItem, exitItem }
            };

            TaskbarIconToolTip = new ToolTip() { Content = Program.AppName };

            TaskbarIcon = new TaskbarIcon()
            {
                TrayToolTip = TaskbarIconToolTip,
                ContextMenu = TaskbarIconContextMenu,
                DoubleClickCommand = CommonCommands.OpenSettingsWindowCommand
            };
        }

        public static void UpdateTrayIconVisibility(bool isVisible)
        {
            TaskbarIcon.Visibility = isVisible ? Visibility.Visible : Visibility.Collapsed;
        }

        public static void UpdateTrayIconInternal(ElementTheme currentTheme, bool useColoredTrayIcon)
        {
            ThemeManager.SetRequestedTheme(TaskbarIconContextMenu, currentTheme);
            ThemeManager.SetRequestedTheme(TaskbarIconToolTip, currentTheme);

            Uri iconUri;
            if (useColoredTrayIcon)
            {
                iconUri = PackUriHelper.GetAbsoluteUri(@"Assets\Logo.ico");
            }
            else
            {
                iconUri = PackUriHelper.GetAbsoluteUri(currentTheme == ElementTheme.Light ? @"Assets\Logo_Tray_Black.ico" : @"Assets\Logo_Tray_White.ico");
            }

            TaskbarIcon.IconSource = BitmapFrame.Create(iconUri);
        }
    }
}

Thanks, Sam

Samuel12321 avatar Sep 19 '21 22:09 Samuel12321

Hi Sam,

That explanation makes a bit more sense, as that what I understood before. I though you meant that the tray icon only shows tooltips and nothing else... It didn't get to me that you ment it doesn't show the correct text 😆

I will look into it, fortunately I do have some Windows 11 to play around with for my Greenshot development.

Btw. nice project.

Best wishes, Robin

Lakritzator avatar Sep 20 '21 07:09 Lakritzator

I can confirm thes issue here too on a fresh Windows 11 install with my app TotalMix Volume Control.

image

Instead of something like:

image

Thanks so much in advance Fotis

fgimian avatar Oct 21 '21 11:10 fgimian

Wondering if this could be the source of the problem, just saw this https://aka.ms/AAd21h2

NIN_POPUPOPEN is never sent when NOTIFYICON_VERSION_4 is specified and NIF_SHOWTIP is not Normally, when apps used notification icons version 4 with Shell_NotifyIcon and did not specify NIF_SHOWTIP, they would receive NIN_POPUPOPEN to be able to show their own tooltip. In Windows 11, these apps never receive NIN_POPUPOPEN and the Windows-default tooltip will always show, which is undesirable for some apps and completely nullifies the point of NIF_SHOWTIP.

Samuel12321 avatar Oct 21 '21 23:10 Samuel12321

@Samuel12321 I was expecting something like that, but didn't find it yet. Yes, that is exactly describing the issue!

Thanks for covering that up.

Please all upvote this: https://aka.ms/AAd21h2

Lakritzator avatar Oct 22 '21 06:10 Lakritzator

@Lakritzator Any ideas on a workaround for this? i doubt MS will fix this quickly.

Samuel12321 avatar Oct 22 '21 06:10 Samuel12321

I don't see an easy way to workaround this, when the right event is missing on a level which is out of our control, it's usually hard to find some way to mitigate this. Mostly this results in a weird & ugly workaround. I myself would rather see if Microsoft can fix this, before someone spends hours of work on it.

We might be able find a Microsoft application which has the same issue, this might speed up fixing it. I tried to have a look already, for me it would have been the best if PowerToys had an issue, but unfortunately it only shows a simple tooltip in Windows 10...

Lakritzator avatar Oct 22 '21 08:10 Lakritzator

I'm the one that filled the Feedback Hub entry linked above - I don't think any fix should be expected soon. We all know that Feedback Hub is like speaking to a wall.

In my case it wasn't too bad because I use the APIs raw from C++ so was able to easily find the issue (and I've always gave an appropriate fallback text, so it only downgrades from a newer tooltip to the old tooltip style in the end). It might be possible to fill an issue on the Windows App SDK repo, as they also own these OS APIs. I'd happily upvote and comment on such an issue.

It might be interesting to check the newer insider builds, since if it was fixed it probably wouldn't qualify for a cumulative update.

sylveon avatar Dec 02 '21 17:12 sylveon

FYI, if someone just sets ToolTipText, would that work as a fallback then on Windows 11? I don't have a non-Windows 11 machine, so I want to make sure setting this doesn't prevent the nice/fancy tool tip from showing up on hover on Windows 10 or previous

Duncanma avatar Dec 07 '21 04:12 Duncanma

FYI, if someone just sets ToolTipText, would that work as a fallback then on Windows 11?

Yes

Symbai avatar Dec 27 '21 13:12 Symbai

There is another bug on Windows 11. By some reason long tooltip texts now showing multiline. Here the sample image On any other Windows version this tooltip is showing as single line. The usage is quite simple.

  <tb:TaskbarIcon x:Name="trayIcon" Visibility="Visible"                           
                                 IconSource="{Binding Path=IconSource}"
                                 ToolTipText="some long long long text"/>

mogikanin avatar Apr 28 '22 09:04 mogikanin