@@ -62,7 +62,7 @@ public class NotifyIcon : FrameworkElement, IDisposable
6262
6363 static NotifyIcon ( )
6464 {
65- VisibilityProperty . OverrideMetadata ( typeof ( NotifyIcon ) , new PropertyMetadata ( Visibility . Visible , OnVisibilityChanged ) ) ;
65+ VisibilityProperty . OverrideMetadata ( typeof ( NotifyIcon ) , new PropertyMetadata ( ValueBoxes . VisibleBox , OnVisibilityChanged ) ) ;
6666 DataContextProperty . OverrideMetadata ( typeof ( NotifyIcon ) , new FrameworkPropertyMetadata ( DataContextPropertyChanged ) ) ;
6767 ContextMenuProperty . OverrideMetadata ( typeof ( NotifyIcon ) , new FrameworkPropertyMetadata ( ContextMenuPropertyChanged ) ) ;
6868 }
@@ -247,7 +247,19 @@ public string Token
247247 }
248248
249249 public static readonly DependencyProperty TextProperty = DependencyProperty . Register (
250- nameof ( Text ) , typeof ( string ) , typeof ( NotifyIcon ) , new PropertyMetadata ( default ( string ) ) ) ;
250+ nameof ( Text ) , typeof ( string ) , typeof ( NotifyIcon ) , new PropertyMetadata ( default ( string ) , OnTextChanged ) ) ;
251+
252+ private static void OnTextChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
253+ {
254+ var ctl = ( NotifyIcon ) d ;
255+
256+ if ( ctl . _windowClassName == null )
257+ {
258+ return ;
259+ }
260+
261+ ctl . UpdateIcon ( ctl . _added , ctl . _isTransparent ) ;
262+ }
251263
252264 public string Text
253265 {
@@ -309,7 +321,6 @@ public TimeSpan BlinkInterval
309321 private static void OnIsBlinkChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
310322 {
311323 var ctl = ( NotifyIcon ) d ;
312- if ( ctl . Visibility != Visibility . Visible ) return ;
313324 if ( ( bool ) e . NewValue )
314325 {
315326 if ( ctl . _dispatcherTimerBlink == null )
@@ -326,7 +337,7 @@ private static void OnIsBlinkChanged(DependencyObject d, DependencyPropertyChang
326337 {
327338 ctl . _dispatcherTimerBlink ? . Stop ( ) ;
328339 ctl . _dispatcherTimerBlink = null ;
329- ctl . UpdateIcon ( true ) ;
340+ ctl . UpdateIcon ( ctl . _added , ctl . _isTransparent ) ;
330341 }
331342 }
332343
0 commit comments