Add close functionality
ADD
WalletWasabi.Gui/Behaviors/CloseWindowBehavior.cs
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Xaml.Interactivity;
+using ReactiveUI;
+using System;
+using System.Reactive.Disposables;
+using System.Reactive.Linq;
+
+namespace WalletWasabi.Gui.Behaviors
+{
+ public class CloseWindowBehavior : Behavior<Window>
+ {
+ public static readonly StyledProperty<bool> CloseTriggerProperty =
+ AvaloniaProperty.Register<Behavior, bool>(nameof(CloseTriggerProperty));
+
+ public bool CloseTrigger
+ {
+ get => GetValue(CloseTriggerProperty);
+ set => SetValue(CloseTriggerProperty, value);
+ }
+
+ private CompositeDisposable Disposables { get; } = new CompositeDisposable();
+
+ protected override void OnAttached()
+ {
+ base.OnAttached();
+
+ this.GetObservable(CloseTriggerProperty)
+ .ObserveOn(RxApp.MainThreadScheduler)
+ .Subscribe(closeTriggered =>
+ {
+ if (closeTriggered)
+ {
+ AssociatedObject.Close();
+ }
+ }).DisposeWith(Disposables);
+ }
+
+ protected override void OnDetaching()
+ {
+ Disposables?.Dispose();
+ base.OnDetaching();
+ }
+ }
+}

MODIFY
WalletWasabi.Gui/CrashReport/ViewModels/CrashReportWindowViewModel.cs
WalletWasabi.Gui/CrashReport/ViewModels/CrashReportWindowViewModel.cs
@@ -5,12 +5,15 @@ using System.Reactive;
using System.Reactive.Linq;
using WalletWasabi.Gui.Controls.WalletExplorer;
using WalletWasabi.Gui.Helpers;
+using WalletWasabi.Gui.ViewModels;
using WalletWasabi.Logging;
namespace WalletWasabi.Gui.CrashReport.ViewModels
{
- public class CrashReportWindowViewModel
+ public class CrashReportWindowViewModel : ViewModelBase
{
+ private bool _closeTrigger;
+
public CrashReportWindowViewModel()
{
var global = Locator.Current.GetService<Global>();
@@ -20,7 +23,7 @@ namespace WalletWasabi.Gui.CrashReport.ViewModels
OkCommand = ReactiveCommand.Create(() =>
{
- // Close the application.
+ CloseTrigger = true;
});
Observable
@@ -37,6 +40,12 @@ namespace WalletWasabi.Gui.CrashReport.ViewModels
public string Details => $"Wasabi has crashed. You can check the details here, open the log file, or report the crash to the support team. {Environment.NewLine}{Environment.NewLine}Please always consider your privacy before sharing any information!";
public string Message => CrashReporter?.SerializedException?.Message;
+ public bool CloseTrigger
+ {
+ get => _closeTrigger;
+ set => this.RaiseAndSetIfChanged(ref _closeTrigger, value);
+ }
+
public ReactiveCommand<Unit, Unit> OpenLogCommand { get; }
public ReactiveCommand<Unit, Unit> OkCommand { get; }
}

MODIFY
WalletWasabi.Gui/CrashReport/Views/CrashReportWindow.xaml
WalletWasabi.Gui/CrashReport/Views/CrashReportWindow.xaml
<cont:MetroWindow xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cont="clr-namespace:AvalonStudio.Shell.Controls;assembly=AvalonStudio.Shell"
+ xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
xmlns:wasabi="clr-namespace:WalletWasabi.Gui.Controls;assembly=WalletWasabi.Gui"
+ xmlns:behaviors="clr-namespace:WalletWasabi.Gui.Behaviors;assembly=WalletWasabi.Gui"
x:Class="WalletWasabi.Gui.CrashReport.Views.CrashReportWindow"
Icon="avares://WalletWasabi.Gui/Assets/WasabiLogo256.png"
Title="{Binding Title}"
WindowState="{Binding WindowState}"
Classes="ToolWindow"
CanResize="False">
+ <i:Interaction.Behaviors>
+ <behaviors:CloseWindowBehavior CloseTrigger="{Binding CloseTrigger}" />
+ </i:Interaction.Behaviors>
<DockPanel LastChildFill="True" Margin="25,0,25,25">
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Right" Spacing="5" Margin="0,25,0,0">
<Button MinWidth="135" Height="35" Command="{Binding OpenLogCommand}">Open logs</Button>

Add close functionality