hardcodet / wpf-notifyicon

NotifyIcon (aka system tray icon or taskbar icon) for the WPF platform
Other
810 stars 125 forks source link

ToolTipText is not showing when using Binding to ToolTipText property #31

Open KevinAllenWiegand opened 4 years ago

KevinAllenWiegand commented 4 years ago

I have the following in my XAML:

`

</tb:TaskbarIcon.TrayToolTip>`

I do have the ToolTipText property defined:

ToolTipText="{StaticResource ApplicationName}"

And that resource is in my App.xaml in a ResourceDictionary:

<system:String x:Key="ApplicationName">This is a test.</system:String>

This same binding is working as the Window Title, so I know it works.

What I get out of this is an empty box with no text. If I change the Binding to a text value that I have defined, it does show up, so I know it's not some strange display issue with the text.

WhatToTheHeck

When I use Visual Studio's built-in "Live Visual Tree", the DataSource on "TaskbarIcon.TrayToolTip" is the associated ViewModel for the Window. If I add a "ToolTipText" property to my ViewModel, then it shows up properly.

According to the "Implicit Binding through DataContext" section of https://www.codeproject.com/Articles/36468/WPF-NotifyIcon-2, it should be binding to the TaskbarIcon, not the ViewModel of the containing window.

I don't know if this is a WPF bug, or something else. My project is targetting .Net Core 3.1, if that matters. I am referencing v1.0.10 of your NotifyIcon.

KevinAllenWiegand commented 4 years ago

CoreWpfTest.zip

Here's my VS2019 project, for reference.

Lakritzator commented 4 years ago

This project doesn't have a 1.0.10 (yet) so you probably have it from here: https://github.com/HavenDV/Hardcodet.NotifyIcon.Wpf.NetCore That is not even a real fork and it doesn't have any history... I'm not sure what is in there, except that it might be my code... I'm not going to check.

Try with 1.0.8, which is not build for dotnet core 3.x but it will work fine except for a warning. It's a bit of a shame, it's only a warning and will function just file, why they can't wait and introduce confusion...

Anyway I don't know what your issue is, it might be the same when you go to Hardcodet.NotifyIcon.Wpf 1.0.8 but I just wanted to point that out.

I'm not the biggest WPF / binding expert, maybe one of the other guys can help you there...

P.S. A newer version which does support dotnet core 3.x is on it's way...

KevinAllenWiegand commented 4 years ago

Huh. That's ... interesting. This is the NuGet package I have, which points me here: NuGetPackage It is that repo you mentioned...but then they kind of have their URL wrong. It is a copy of your code, that they apparently made changes to and published. I'll try your version specifically.

KevinAllenWiegand commented 4 years ago

I changed to your version and have the same issue. :/ I have more than beginner, but not quite advanced knowledge of WPF and bindings...I've certainly done my fair share, but there's a lot I know I don't know...I'll maybe keep digging...for the moment, I just have a StaticResource that I'm using in both to get around it.