WinUI3 H.NotifyIcon, Unable to resolve symbol TaskbarIcon

313 views Asked by At

I am working on a winui3 project, and for notify icon, only good option I found is HavenDV/H.NotifyIcon

For winui, it recommends H.NotifyIcon.WinUI, but it is having version issues and showing enter image description here

So, I tried to add the core library H.NotifyIcon, which supposedly works for all the platforms, but it is showing Unable to resolve symbol 'TaskbarIcon'

enter image description here

So, what I am doing wrong?

2

There are 2 answers

0
Andrew KeepCoding On BEST ANSWER

From the error message, I guess you are getting this error because, the latest H.NotifyIcon.WinUI requires WindowsAppSDK v1.2.230217.4 or later, but your app has WindowsAppSDK v1.2.221109.1 installed.

Updating WindowsAppSDK to the latest version should fix your problem.

0
Jeaninez - MSFT On

I test it and I couldn't reproduce the issue.

1,In manage nuget packages, find the H.NotifyIcon.winui package and install it.

enter image description here

2,Declared within MainWindow

<Window
        xmlns:tb="clr-namespace:H.NotifyIcon;assembly=H.NotifyIcon.Wpf" // WPF
    xmlns:tb="using:H.NotifyIcon" // WinUI
    >
        <tb:TaskbarIcon
            ToolTipText="ToolTip"
        IconSource="/Images/TrayIcons/Logo.ico"
            ContextFlyout="{StaticResource TrayMenu}"
            MenuActivation="LeftOrRightClick"
            TrayPopup="{StaticResource TrayStatusPopup}"
            PopupActivation="DoubleClick"
            TrayToolTip="{StaticResource TrayToolTip}"
            />
</Window>

Note: 1,WinUI uses ContextFlyout instead ContextMenu.

2,Microsoft.WindowsAppSDK>=1.2.230217.4

For more details I suggest you could refer to the link:

https://github.com/HavenDV/H.NotifyIcon