Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

center window don't work #188

Open
PepiBobanov opened this issue May 4, 2022 · 1 comment
Open

center window don't work #188

PepiBobanov opened this issue May 4, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@PepiBobanov
Copy link

Create new AdonisWindow with SizeToContent="WidthAndHeight" and WindowStartupLocation="CenterOwner"

Owner = parent
ShowDialog()

window is not centered :(

@PepiBobanov PepiBobanov added the bug Something isn't working label May 4, 2022
@PepiBobanov
Copy link
Author

It become Help yourself thing :)
window.SizeChanged += (s, e) => CenterOwner(window);

    private void CenterOwner( Window w)
    {
        if (w.Owner != null)
        {
            double top = w.Owner.Top + ((w.Owner.Height - w.ActualHeight) / 2);
            double left = w.Owner.Left + ((w.Owner.Width - w.ActualWidth) / 2);

            w.Top = top < 0 ? 0 : top;
            w.Left = left < 0 ? 0 : left;
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant