Call SetWindowSize before calling Show() method for main window
MODIFY
WalletWasabi.Fluent/ApplicationStateManager.cs
WalletWasabi.Fluent/ApplicationStateManager.cs
using System.ComponentModel;
using System.Reactive.Disposables;
using System.Reactive.Linq;
+using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using ReactiveUI;
+using WalletWasabi.Fluent.Behaviors;
using WalletWasabi.Fluent.Helpers;
using WalletWasabi.Fluent.Providers;
using WalletWasabi.Fluent.State;
@@ -158,11 +160,37 @@ public class ApplicationStateManager : IMainWindowService
_lifetime.MainWindow = result;
+ if (result.WindowState != WindowState.Maximized)
+ {
+ SetWindowSize(result);
+ }
+
result.Show();
ApplicationViewModel.IsMainWindowShown = true;
}
+ private void SetWindowSize(Window window)
+ {
+ var configWidth = Services.UiConfig.WindowWidth;
+ var configHeight = Services.UiConfig.WindowHeight;
+ var currentScreen = window.Screens.ScreenFromPoint(window.Position);
+
+ if (configWidth is null || configHeight is null || currentScreen is null)
+ {
+ return;
+ }
+
+ var isValidWidth = configWidth <= currentScreen.WorkingArea.Width && configWidth >= window.MinWidth;
+ var isValidHeight = configHeight <= currentScreen.WorkingArea.Height && configHeight >= window.MinHeight;
+
+ if (isValidWidth && isValidHeight)
+ {
+ window.Width = configWidth.Value;
+ window.Height = configHeight.Value;
+ }
+ }
+
void IMainWindowService.Show()
{
_stateMachine.Fire(Trigger.Show);

MODIFY
WalletWasabi.Fluent/Behaviors/WindowSizeBehavior.cs
WalletWasabi.Fluent/Behaviors/WindowSizeBehavior.cs
using System.Reactive.Disposables;
using System.Reactive.Linq;
using Avalonia.Controls;
+using Avalonia.Threading;
using ReactiveUI;
namespace WalletWasabi.Fluent.Behaviors;
@@ -15,11 +16,6 @@ public class WindowSizeBehavior : DisposingBehavior<Window>
.Take(1)
.Subscribe(_ =>
{
- if (AssociatedObject.WindowState != WindowState.Maximized)
- {
- SetWindowSize(AssociatedObject);
- }
-
AssociatedObject
.WhenAnyValue(x => x.Bounds)
.Skip(1)
@@ -33,25 +29,4 @@ public class WindowSizeBehavior : DisposingBehavior<Window>
})
.DisposeWith(disposables);
}
-
- private void SetWindowSize(Window window)
- {
- var configWidth = Services.UiConfig.WindowWidth;
- var configHeight = Services.UiConfig.WindowHeight;
- var currentScreen = window.Screens.ScreenFromPoint(window.Position);
-
- if (configWidth is null || configHeight is null || currentScreen is null)
- {
- return;
- }
-
- var isValidWidth = configWidth <= currentScreen.WorkingArea.Width && configWidth >= window.MinWidth;
- var isValidHeight = configHeight <= currentScreen.WorkingArea.Height && configHeight >= window.MinHeight;
-
- if (isValidWidth && isValidHeight)
- {
- window.Width = configWidth.Value;
- window.Height = configHeight.Value;
- }
- }
}

Call SetWindowSize before calling Show() method for main window