Add Tray click functionality
MODIFY
WalletWasabi.Fluent/App.axaml
WalletWasabi.Fluent/App.axaml
<TrayIcon.Icons>
<TrayIcons>
- <TrayIcon Icon="/Assets/WasabiLogo.ico">
+ <TrayIcon Icon="/Assets/WasabiLogo.ico" Clicked="TrayIcon_OnClicked">
<NativeMenu.Menu>
<NativeMenu>
<NativeMenuItem Header="Show" Command="{Binding ShowCommand} " />

MODIFY
WalletWasabi.Fluent/App.axaml.cs
WalletWasabi.Fluent/App.axaml.cs
@@ -28,7 +28,9 @@ namespace WalletWasabi.Fluent
public App()
{
Name = "Wasabi Wallet";
- DataContext = new ApplicationViewModel();
+ ApplicationViewModel applicationViewModel = new();
+ DataContext = applicationViewModel;
+ applicationViewModel.ShowRequested += (sender, args) => ShowRequested?.Invoke(sender, args);
}
public App(Func<Task> backendInitialiseAsync) : this()
@@ -36,6 +38,8 @@ namespace WalletWasabi.Fluent
_backendInitialiseAsync = backendInitialiseAsync;
}
+ public event EventHandler? ShowRequested;
+
public ICanShutdownProvider? CanShutdownProvider
{
get => GetValue(CanShutdownProviderProperty);
@@ -86,5 +90,10 @@ namespace WalletWasabi.Fluent
Logger.LogDebug($"Cancellation of the shutdown set to: {e.Cancel}.");
}
}
+
+ private void TrayIcon_OnClicked(object? sender, EventArgs e)
+ {
+ ShowRequested?.Invoke(this, EventArgs.Empty);
+ }
}
}

MODIFY
WalletWasabi.Fluent/Behaviors/HideShowBehavior.cs
WalletWasabi.Fluent/Behaviors/HideShowBehavior.cs
@@ -25,7 +25,7 @@ namespace WalletWasabi.Fluent.Behaviors
{
Observable.Merge(
Observable.FromEventPattern(Services.SingleInstanceChecker, nameof(SingleInstanceChecker.OtherInstanceStarted)),
- Observable.FromEventPattern(((ApplicationViewModel)Application.Current.DataContext!), nameof(ApplicationViewModel.ShowRequested)))
+ Observable.FromEventPattern(((App)Application.Current!), nameof(App.ShowRequested)))
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(_ =>
{

Add Tray click functionality