ClientSizeProperty.Changed.Subscribe(size =>
{
var x = (size.OldValue.Value.Width - size.NewValue.Value.Width) / 2 * Scaling;
var y = (size.OldValue.Value.Height - size.NewValue.Value.Height) / 2 * Scaling;
Position = new PixelPoint(Position.X + (int)x, Position.Y + (int)y);
});
public double Scaling => Screens.ScreenFromWindow(this)!.Scaling;
I need to multiply x
and y
by window scaling factor. Otherwise, the window would slowly shift.
Is this the right way to fix?