diff --git a/src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs b/src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs index fc87cbb4..25098b63 100644 --- a/src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs +++ b/src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs @@ -85,21 +85,7 @@ namespace HandyControl.Controls _id = ++NextId; _callback = Callback; - Loaded += (s, e) => - { - RegisterClass(); - if (Visibility == Visibility.Visible) - { - OnIconChanged(); - UpdateIcon(true); - } - - _dispatcherTimerPos = new DispatcherTimer - { - Interval = TimeSpan.FromMilliseconds(200) - }; - _dispatcherTimerPos.Tick += DispatcherTimerPos_Tick; - }; + Loaded += (s, e) => Init(); if (Application.Current != null) Application.Current.Exit += (s, e) => Dispose(); } @@ -109,6 +95,22 @@ namespace HandyControl.Controls Dispose(false); } + public void Init() + { + RegisterClass(); + if (Visibility == Visibility.Visible) + { + OnIconChanged(); + UpdateIcon(true); + } + + _dispatcherTimerPos = new DispatcherTimer + { + Interval = TimeSpan.FromMilliseconds(200) + }; + _dispatcherTimerPos.Tick += DispatcherTimerPos_Tick; + } + public static readonly DependencyProperty TextProperty = DependencyProperty.Register( "Text", typeof(string), typeof(NotifyIcon), new PropertyMetadata(default(string)));