remove persisting window size as it cant be implemented correctly pending some avalonia api changes
DELETE
WalletWasabi.Gui/Behaviors/BindWindowSizeBehavior.cs
-using Avalonia;
-using Avalonia.Controls;
-using Avalonia.Xaml.Interactivity;
-using System;
-using System.Linq;
-using System.Reactive.Disposables;
-using System.Reactive.Linq;
-
-namespace WalletWasabi.Gui.Behaviors
-{
- public class BindWindowSizeBehavior : Behavior<Window>
- {
- private Size _maxSize;
- private CompositeDisposable _disposables;
-
- /// <summary>
- /// Defines the <see cref="Width"/> property.
- /// </summary>
- public static readonly StyledProperty<double> WidthProperty =
- AvaloniaProperty.Register<BindWindowSizeBehavior, double>(nameof(Width), double.NaN);
-
- /// <summary>
- /// Defines the <see cref="Height"/> property.
- /// </summary>
- public static readonly StyledProperty<double> HeightProperty =
- AvaloniaProperty.Register<BindWindowSizeBehavior, double>(nameof(Height), double.NaN);
-
- /// <summary>
- /// Gets or sets the width of the element.
- /// </summary>
- public double Width
- {
- get => GetValue(WidthProperty);
- set => SetValue(WidthProperty, value);
- }
-
- /// <summary>
- /// Gets or sets the height of the element.
- /// </summary>
- public double Height
- {
- get => GetValue(HeightProperty);
- set => SetValue(HeightProperty, value);
- }
-
- protected override void OnAttached()
- {
- base.OnAttached();
-
- _disposables?.Dispose();
-
- _disposables = new CompositeDisposable();
-
- Observable.FromEventPattern(AssociatedObject, nameof(AssociatedObject.Opened))
- .Subscribe(_ => AssociatedObject_Opened())
- .DisposeWith(_disposables);
- }
-
- protected override void OnDetaching()
- {
- base.OnDetaching();
-
- _disposables?.Dispose();
- _disposables = null;
- }
-
- private void AssociatedObject_Opened()
- {
- var screen = AssociatedObject.Screens.ScreenFromVisual(AssociatedObject);
-
- _maxSize = screen.WorkingArea.Size.ToSize(screen.PixelDensity) * 0.95;
-
- this.GetObservable(HeightProperty)
- .Where(x => !double.IsNaN(x))
- .Subscribe(x =>
- {
- if (AssociatedObject.WindowState == WindowState.Normal)
- {
- AssociatedObject.Height = x >= _maxSize.Height ? _maxSize.Height : x;
- }
- });
-
- this.GetObservable(WidthProperty)
- .Where(x => !double.IsNaN(x))
- .Subscribe(x =>
- {
- if (AssociatedObject.WindowState == WindowState.Normal)
- {
- AssociatedObject.Width = x >= _maxSize.Width ? _maxSize.Width : x;
- }
- });
- }
- }
-}

MODIFY
WalletWasabi.Gui/MainWindow.xaml
WalletWasabi.Gui/MainWindow.xaml
xmlns:behaviors="clr-namespace:WalletWasabi.Gui.Behaviors;assembly=WalletWasabi.Gui"
xmlns:shell="clr-namespace:AvalonStudio.Shell;assembly=AvalonStudio.Shell"
xmlns:menu="clr-namespace:AvalonStudio.Shell.Extensibility.MainMenu.Views;assembly=AvalonStudio.Shell.Extensibility"
- xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
- xmlns:ia="clr-namespace:Avalonia.Xaml.Interactions.Core;assembly=Avalonia.Xaml.Interactions"
xmlns:id="clr-namespace:Dock.Avalonia;assembly=Dock.Avalonia"
xmlns:idc="clr-namespace:Dock.Avalonia.Controls;assembly=Dock.Avalonia"
- xmlns:beh="clr-namespace:WalletWasabi.Gui.Behaviors"
x:Class="WalletWasabi.Gui.MainWindow"
Icon="avares://WalletWasabi.Gui/Assets/WasabiLogo256.png"
Title="{Binding Title}"
WindowState="{Binding WindowState}"
UseLayoutRounding="True"
RenderOptions.BitmapInterpolationMode="HighQuality">
- <i:Interaction.Behaviors>
- <beh:BindWindowSizeBehavior Width="{Binding Width}" Height="{Binding Height}" />
- </i:Interaction.Behaviors>
<cont:MetroWindow.TitleBarContent>
<StackPanel Orientation="Horizontal" IsVisible="{Binding MenuVisible}">
<menu:MainMenuView DataContext="{Binding Shell.MainMenu}" Margin="4 0 0 0" Foreground="{DynamicResource ThemeForegroundBrush}" VerticalAlignment="Stretch" FontSize="13" />

MODIFY
WalletWasabi.Gui/MainWindow.xaml.cs
WalletWasabi.Gui/MainWindow.xaml.cs
@@ -104,12 +104,6 @@ namespace WalletWasabi.Gui
{
Global.UiConfig.WindowState = WindowState;
- if (WindowState == Avalonia.Controls.WindowState.Normal)
- {
- Global.UiConfig.Width = Width;
- Global.UiConfig.Height = Height;
- }
-
Global.UiConfig.LastActiveTab = IoC.Get<IShell>().SelectedDocument?.GetType().Name;
Global.UiConfig.ToFile();
Logger.LogInfo($"{nameof(Global.UiConfig)} is saved.");

MODIFY
WalletWasabi.Gui/UiConfig.cs
WalletWasabi.Gui/UiConfig.cs
@@ -39,14 +39,6 @@ namespace WalletWasabi.Gui
[JsonConverter(typeof(WindowStateAfterStartJsonConverter))]
public WindowState WindowState { get; internal set; } = WindowState.Maximized;
- [DefaultValue(530)]
- [JsonProperty(PropertyName = "Height", DefaultValueHandling = DefaultValueHandling.Populate)]
- public double Height { get; internal set; }
-
- [DefaultValue(1100)]
- [JsonProperty(PropertyName = "Width", DefaultValueHandling = DefaultValueHandling.Populate)]
- public double Width { get; internal set; }
-
[DefaultValue(2)]
[JsonProperty(PropertyName = "FeeTarget", DefaultValueHandling = DefaultValueHandling.Populate)]
public int FeeTarget { get; internal set; }

MODIFY
WalletWasabi.Gui/ViewModels/MainWindowViewModel.cs
WalletWasabi.Gui/ViewModels/MainWindowViewModel.cs
@@ -23,8 +23,6 @@ namespace WalletWasabi.Gui.ViewModels
private ModalDialogViewModelBase _modalDialog;
private bool _canClose = true;
private string _title = "Wasabi Wallet";
- private double _height;
- private double _width;
private WindowState _windowState;
private StatusBarViewModel _statusBar;
private LockScreenViewModelBase _lockScreen;
@@ -44,9 +42,6 @@ namespace WalletWasabi.Gui.ViewModels
var uiConfig = global.UiConfig;
- Width = uiConfig.Width;
- Height = uiConfig.Height;
-
WindowState = uiConfig.WindowState;
InitializeLockScreen(global.UiConfig);
@@ -62,18 +57,6 @@ namespace WalletWasabi.Gui.ViewModels
internal set => this.RaiseAndSetIfChanged(ref _title, value);
}
- public double Height
- {
- get => _height;
- set => this.RaiseAndSetIfChanged(ref _height, value);
- }
-
- public double Width
- {
- get => _width;
- set => this.RaiseAndSetIfChanged(ref _width, value);
- }
-
public WindowState WindowState
{
get => _windowState;

remove persisting window size as it cant be implemented correctly pending some avalonia api changes