Skip to content

In WindowBase.PositionChanged event handler Point value is wrong #14604

Closed
@sinatrocious

Description

@sinatrocious

Describe the bug

The value of PixelPointEvenArgs.Point inside event handler is wrong.

To Reproduce

Steps to reproduce the behavior:

  1. Create new Avalonia C# project.
  2. In MainWindow.axaml.cs add line in constructor to output argument value and actual value:
    public MainWindow()
    {
        InitializeComponent();
        PositionChanged += (s, e) => Debug.WriteLine($"Position={e.Point}, actual={Position}");
        //Position = new(666, 666); // optional
    }
  1. Run and observe debugger "Output" window.
  2. My outputs are
Position=190, 213, actual=188, 182
or
Position=668, 697, actual=666, 666

Expected behavior

I expect e.Point value to be equal to actual window Position.

Environment

  • OS: Windows 11
  • Avalonia-Version: 11.0.9

Additional context

I tried to use PositionChanged event to store position of window in normal state, see #14517 ,but unfortunately discovered a new frustrating bug in Avalonia.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bughelp-wantedA contribution from the community would be most welcome.os-windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions