From b5df379f1b08760bf392f82742732a0082625a44 Mon Sep 17 00:00:00 2001 From: punker76 Date: Sat, 5 Oct 2024 12:58:00 +0200 Subject: [PATCH 1/2] fix: #19 call UpdateDefaultStyle for context menu and popup to make sure the correct dynamic resources are loaded --- src/NotifyIconWpf/TaskbarIcon.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NotifyIconWpf/TaskbarIcon.cs b/src/NotifyIconWpf/TaskbarIcon.cs index 1358d82..84ae7f1 100644 --- a/src/NotifyIconWpf/TaskbarIcon.cs +++ b/src/NotifyIconWpf/TaskbarIcon.cs @@ -244,6 +244,9 @@ public void ShowCustomBalloon(UIElement balloon, PopupAnimation animation, int? // fire attached event RaiseBalloonShowingEvent(balloon, this); + // To apply DynamicResource changes (related to issue on GitHub for TaskbarIcon: https://github.com/hardcodet/wpf-notifyicon/issues/19) + popup.UpdateDefaultStyle(); + // display item popup.IsOpen = true; @@ -676,6 +679,9 @@ public void ShowTrayPopup() // place the popup PlacePopup(PopupPlacement); + // To apply DynamicResource changes (related to issue on GitHub for TaskbarIcon: https://github.com/hardcodet/wpf-notifyicon/issues/19) + TrayPopupResolved.UpdateDefaultStyle(); + // open popup TrayPopupResolved.IsOpen = true; @@ -747,6 +753,9 @@ private void ShowContextMenu(Point cursorPosition) return; } + // To apply DynamicResource changes (related to issue on GitHub for TaskbarIcon: https://github.com/hardcodet/wpf-notifyicon/issues/19) + ContextMenu.UpdateDefaultStyle(); + // use absolute positioning. We need to set the coordinates, or a delayed opening // (e.g. when left-clicked) opens the context menu at the wrong place if the mouse // is moved! From 85e202bd0157192527c5ed75dbe345aa38f8eb0f Mon Sep 17 00:00:00 2001 From: punker76 Date: Sat, 5 Oct 2024 12:58:17 +0200 Subject: [PATCH 2/2] reafctor: improve inline popup sample --- .../Commands/CloseWindowCommand.cs | 9 +++++++-- .../Tutorials/03 - Popups/InlinePopupWindow.xaml | 3 +-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/NotifyIconWpf.Sample.ShowCases/Commands/CloseWindowCommand.cs b/src/NotifyIconWpf.Sample.ShowCases/Commands/CloseWindowCommand.cs index 0c086ce..66c1bbb 100644 --- a/src/NotifyIconWpf.Sample.ShowCases/Commands/CloseWindowCommand.cs +++ b/src/NotifyIconWpf.Sample.ShowCases/Commands/CloseWindowCommand.cs @@ -5,6 +5,7 @@ using System.Windows; using System.Windows.Input; +using Hardcodet.Wpf.TaskbarNotification; namespace NotifyIconWpf.Sample.ShowCases.Commands { @@ -15,8 +16,12 @@ public class CloseWindowCommand : CommandBase { public override void Execute(object parameter) { - GetTaskbarWindow(parameter).Close(); - CommandManager.InvalidateRequerySuggested(); + if (parameter is TaskbarIcon taskbarIcon) + { + taskbarIcon.CloseTrayPopup(); + GetTaskbarWindow(taskbarIcon).Close(); + CommandManager.InvalidateRequerySuggested(); + } } diff --git a/src/NotifyIconWpf.Sample.ShowCases/Tutorials/03 - Popups/InlinePopupWindow.xaml b/src/NotifyIconWpf.Sample.ShowCases/Tutorials/03 - Popups/InlinePopupWindow.xaml index 5937d57..85a7729 100644 --- a/src/NotifyIconWpf.Sample.ShowCases/Tutorials/03 - Popups/InlinePopupWindow.xaml +++ b/src/NotifyIconWpf.Sample.ShowCases/Tutorials/03 - Popups/InlinePopupWindow.xaml @@ -22,8 +22,7 @@ Background="White" BorderBrush="Orange" BorderThickness="2" - CornerRadius="4" - Width="160"> + CornerRadius="4">