@@ -62,7 +62,7 @@ public class NotifyIcon : FrameworkElement, IDisposable
62
62
63
63
static NotifyIcon ( )
64
64
{
65
- VisibilityProperty . OverrideMetadata ( typeof ( NotifyIcon ) , new PropertyMetadata ( Visibility . Visible , OnVisibilityChanged ) ) ;
65
+ VisibilityProperty . OverrideMetadata ( typeof ( NotifyIcon ) , new PropertyMetadata ( ValueBoxes . VisibleBox , OnVisibilityChanged ) ) ;
66
66
DataContextProperty . OverrideMetadata ( typeof ( NotifyIcon ) , new FrameworkPropertyMetadata ( DataContextPropertyChanged ) ) ;
67
67
ContextMenuProperty . OverrideMetadata ( typeof ( NotifyIcon ) , new FrameworkPropertyMetadata ( ContextMenuPropertyChanged ) ) ;
68
68
}
@@ -247,7 +247,19 @@ public string Token
247
247
}
248
248
249
249
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
+ }
251
263
252
264
public string Text
253
265
{
@@ -309,7 +321,6 @@ public TimeSpan BlinkInterval
309
321
private static void OnIsBlinkChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
310
322
{
311
323
var ctl = ( NotifyIcon ) d ;
312
- if ( ctl . Visibility != Visibility . Visible ) return ;
313
324
if ( ( bool ) e . NewValue )
314
325
{
315
326
if ( ctl . _dispatcherTimerBlink == null )
@@ -326,7 +337,7 @@ private static void OnIsBlinkChanged(DependencyObject d, DependencyPropertyChang
326
337
{
327
338
ctl . _dispatcherTimerBlink ? . Stop ( ) ;
328
339
ctl . _dispatcherTimerBlink = null ;
329
- ctl . UpdateIcon ( true ) ;
340
+ ctl . UpdateIcon ( ctl . _added , ctl . _isTransparent ) ;
330
341
}
331
342
}
332
343
0 commit comments