remove unnecessary plumbing for trayicon show command.
MODIFY
WalletWasabi.Fluent/App.axaml
WalletWasabi.Fluent/App.axaml
x:DataType="vm:ApplicationViewModel"
x:CompileBindings="True"
x:Class="WalletWasabi.Fluent.App" CanShutdownProvider="{Binding .}">
+ <Application.DataContext>
+ <vm:ApplicationViewModel />
+ </Application.DataContext>
+
<Application.DataTemplates>
<local:ViewLocator />
<DataTemplate DataType="models:ErrorDescriptor" x:DataType="models:ErrorDescriptor">
<TrayIcon.Icons>
<TrayIcons>
- <TrayIcon Icon="/Assets/WasabiLogo.ico" Clicked="TrayIcon_OnClicked">
+ <TrayIcon Icon="/Assets/WasabiLogo.ico" Command="{Binding ShowCommand}">
<NativeMenu.Menu>
<NativeMenu>
<NativeMenuItem Header="Show" Command="{Binding ShowCommand} " />

MODIFY
WalletWasabi.Fluent/App.axaml.cs
WalletWasabi.Fluent/App.axaml.cs
@@ -28,9 +28,6 @@ namespace WalletWasabi.Fluent
public App()
{
Name = "Wasabi Wallet";
- ApplicationViewModel applicationViewModel = new();
- DataContext = applicationViewModel;
- applicationViewModel.ShowRequested += (sender, args) => ShowRequested?.Invoke(sender, args);
}
public App(Func<Task> backendInitialiseAsync) : this()
@@ -38,8 +35,6 @@ namespace WalletWasabi.Fluent
_backendInitialiseAsync = backendInitialiseAsync;
}
- public event EventHandler? ShowRequested;
-
public ICanShutdownProvider? CanShutdownProvider
{
get => GetValue(CanShutdownProviderProperty);
@@ -90,12 +85,5 @@ namespace WalletWasabi.Fluent
Logger.LogDebug($"Cancellation of the shutdown set to: {e.Cancel}.");
}
}
-
- // Note, this is only supported on Win32 and some Linux DEs
- // https://github.com/AvaloniaUI/Avalonia/blob/99d983499f5412febf07aafe2bf03872319b412b/src/Avalonia.Controls/TrayIcon.cs#L66
- private void TrayIcon_OnClicked(object? sender, EventArgs e)
- {
- ShowRequested?.Invoke(this, EventArgs.Empty);
- }
}
}

remove unnecessary plumbing for trayicon show command.