Browse Source

demo tray icon constantly shown and hidden.

pull/6610/head
Dan Walmsley 5 years ago
parent
commit
4e350e64d8
  1. 12
      src/Avalonia.Controls/TrayIcon.cs

12
src/Avalonia.Controls/TrayIcon.cs

@ -1,9 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Avalonia.Collections; using Avalonia.Collections;
using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Controls.Platform; using Avalonia.Controls.Platform;
using Avalonia.Platform; using Avalonia.Platform;
using Avalonia.Threading;
#nullable enable #nullable enable
@ -25,12 +27,16 @@ namespace Avalonia.Controls
_impl.OnClicked = () => Clicked?.Invoke(this, EventArgs.Empty); _impl.OnClicked = () => Clicked?.Invoke(this, EventArgs.Empty);
Clicked += TrayIcon_Clicked; var timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += Timer_Tick;
timer.Start();
} }
private void TrayIcon_Clicked(object sender, EventArgs e) private void Timer_Tick(object sender, EventArgs e)
{ {
IsVisible = !IsVisible;
} }
public TrayIcon () : this(PlatformManager.CreateTrayIcon()) public TrayIcon () : this(PlatformManager.CreateTrayIcon())

Loading…
Cancel
Save