From cb3721ce48e41b678d7c1b070de7d3f84ab5a8a7 Mon Sep 17 00:00:00 2001 From: Philipp Sumi Date: Fri, 22 Nov 2013 23:03:56 +0000 Subject: [PATCH] FIX ToolTipText changes update an existing wrapper ToolTip, if there is already one. NTFY-23 git-svn-id: https://svn.evolvesoftware.ch/repos/evolve.net/WPF/NotifyIcon@195 9f600761-6f11-4665-b6dc-0185e9171623 --- Source/NotifyIconWpf/TaskbarIcon.Declarations.cs | 16 +++++++++++++--- Source/NotifyIconWpf/TaskbarIcon.cs | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Source/NotifyIconWpf/TaskbarIcon.Declarations.cs b/Source/NotifyIconWpf/TaskbarIcon.Declarations.cs index 2956ce4..4b72aeb 100644 --- a/Source/NotifyIconWpf/TaskbarIcon.Declarations.cs +++ b/Source/NotifyIconWpf/TaskbarIcon.Declarations.cs @@ -298,10 +298,20 @@ namespace Hardcodet.Wpf.TaskbarNotification /// Provides information about the updated property. private void OnToolTipTextPropertyChanged(DependencyPropertyChangedEventArgs e) { - //only recreate tooltip if we're not using a custom control - if (TrayToolTipResolved == null || TrayToolTipResolved.Content is string) + //do not touch tooltips if we have a custom tooltip element + if (TrayToolTip == null) { - CreateCustomToolTip(); + ToolTip currentToolTip = TrayToolTipResolved; + if (currentToolTip == null) + { + //if we don't have a wrapper tooltip for the tooltip text, create it now + CreateCustomToolTip(); + } + else + { + //if we have a wrapper tooltip that shows the old tooltip text, just update content + currentToolTip.Content = e.NewValue; + } } WriteToolTipSettings(); diff --git a/Source/NotifyIconWpf/TaskbarIcon.cs b/Source/NotifyIconWpf/TaskbarIcon.cs index e01b0c0..f9bb617 100644 --- a/Source/NotifyIconWpf/TaskbarIcon.cs +++ b/Source/NotifyIconWpf/TaskbarIcon.cs @@ -522,7 +522,7 @@ namespace Hardcodet.Wpf.TaskbarNotification if (tt == null && TrayToolTip != null) { - //create an invisible tooltip that hosts the UIElement + //create an invisible wrapper tooltip that hosts the UIElement tt = new ToolTip(); tt.Placement = PlacementMode.Mouse; @@ -542,7 +542,7 @@ namespace Hardcodet.Wpf.TaskbarNotification } else if (tt == null && !String.IsNullOrEmpty(ToolTipText)) { - //create a simple tooltip for the string + //create a simple tooltip for the ToolTipText string tt = new ToolTip(); tt.Content = ToolTipText; }