wpf-notifyicon
wpf-notifyicon copied to clipboard
ToolTipText is not showing when using Binding to ToolTipText property
I have the following in my XAML:
<tb:TaskbarIcon.TrayToolTip> <Border Background="White" BorderBrush="Black" BorderThickness="2" CornerRadius="4" Opacity="0.8" Width="160" Padding="5"> <TextBlock Text="{Binding ToolTipText}" Foreground="Black" TextAlignment="Center" TextWrapping="WrapWithOverflow" /> </Border> </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.
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.
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...
Huh. That's ... interesting. This is the NuGet package I have, which points me here:
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.
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.