Fixed MainWindow initial position
MODIFY
WalletWasabi.Fluent/Behaviors/MainWindowPersistPositionBehavior.cs
WalletWasabi.Fluent/Behaviors/MainWindowPersistPositionBehavior.cs
@@ -31,7 +31,8 @@ public class MainWindowBindPositionBehavior : DisposingBehavior<Window>
.DisposeWith(disposables);
vm.WhenAnyValue(x => x.WindowPosition)
- .Subscribe(x => AssociatedObject.Position = x)
+ .Where(x => x is { })
+ .Subscribe(x => AssociatedObject.Position = x.Value)
.DisposeWith(disposables);
SetInitialPosition(vm);
@@ -45,7 +46,12 @@ public class MainWindowBindPositionBehavior : DisposingBehavior<Window>
return;
}
- var position = vm.WindowPosition;
+ var centerX = (int)((AssociatedObject!.Screens.Primary.Bounds.Width - vm.WindowWidth) / 2);
+ var centerY = (int)((AssociatedObject!.Screens.Primary.Bounds.Height - vm.WindowHeight) / 2);
+
+ var position =
+ vm.WindowPosition
+ ??= new PixelPoint(centerX, centerY);
var isValidLeft =
AssociatedObject!.Screens.All.Any(s => s.Bounds.X <= position.X);
@@ -62,12 +68,12 @@ public class MainWindowBindPositionBehavior : DisposingBehavior<Window>
var x =
isValidLeft && isValidRight
? position.X
- : (int)((AssociatedObject.Screens.Primary.Bounds.Width - vm.WindowWidth) / 2);
+ : centerX;
var y =
isValidTop && isValidBottom
? position.Y
- : (int)((AssociatedObject.Screens.Primary.Bounds.Height - vm.WindowHeight) / 2);
+ : centerY;
AssociatedObject.Position = new PixelPoint(x, y);

MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
@@ -42,7 +42,7 @@ public partial class MainViewModel : ViewModelBase
[AutoNotify] private bool _isCoinJoinActive;
[AutoNotify] private double _windowWidth;
[AutoNotify] private double _windowHeight;
- [AutoNotify] private PixelPoint _windowPosition;
+ [AutoNotify] private PixelPoint? _windowPosition;
public MainViewModel()
{
@@ -97,8 +97,12 @@ public partial class MainViewModel : ViewModelBase
.Subscribe(t =>
{
Services.UiConfig.WindowState = t.Item1.ToString();
- Services.UiConfig.WindowX = t.Item2.X;
- Services.UiConfig.WindowY = t.Item2.Y;
+ if (t.Item2 is { })
+ {
+ Services.UiConfig.WindowX = t.Item2.Value.X;
+ Services.UiConfig.WindowY = t.Item2.Value.Y;
+ }
+
Services.UiConfig.WindowWidth = t.Item3;
Services.UiConfig.WindowHeight = t.Item4;
});

Fixed MainWindow initial position