lepoco / wpfui

WPF UI provides the Fluent experience in your known and loved WPF framework. Intuitive design, themes, navigation and new immersive controls. All natively and effortlessly.
https://wpfui.lepo.co
MIT License
7.04k stars 667 forks source link

MessageBox WindowStartupLocation does not work #1045

Open maslewandowski opened 2 months ago

maslewandowski commented 2 months ago

Describe the bug

When showing the custom Messagebox in namespace Wpf.Ui.Controls.MessageBox it is not possible to set the messagebox start up location to center owner. therefore the messagebox is always shown at the center location where the app did start.

To Reproduce

var uiMessageBox = new Wpf.Ui.Controls.MessageBox
{
    Title = "test",
    Content = "test",
    WindowStartupLocation = WindowStartupLocation.CenterOwner
};
await uiMessageBox.ShowDialogAsync();

Expected behavior

It should be shown in the center of the owner window

Screenshots

No response

OS version

windows 11 pro 23H2 22631.3374

.NET version

Target: net8.0-windows7.0

WPF-UI NuGet version

3.0.0-preview.13

Additional context

No response

SlimeNull commented 2 months ago

You need to set the owner of the window first

SlimeNull commented 2 months ago

Like this:

var uiMessageBox = new Wpf.Ui.Controls.MessageBox
{
    Title = "test",
    Content = "test",
    WindowStartupLocation = WindowStartupLocation.CenterOwner
};
uiMessageBox.Owner = Application.Current.MainWindow;
await uiMessageBox.ShowDialogAsync();
m0lDaViA commented 2 months ago

@maslewandowski Does that fix your issue? If yeas, please close this issue.

FaisalMangattil commented 1 month ago

I am also facing the same issue, Even setting the Owner not resolved the issue. Message box always showing in the center of the screen

               var messageBox = new Wpf.Ui.Controls.MessageBox();
                if (!string.IsNullOrEmpty(title))
                    messageBox.Title = title;
                messageBox.Content = message;
                    messageBox.Owner = owner;
                    messageBox.WindowStartupLocation = WindowStartupLocation.CenterOwner;                                         
                messageBox.CloseButtonText = "OK";
                messageBox.ShowDialogAsync();
textGamex commented 3 weeks ago

The current logic only allows display in the center of the screen, and I am seeking a solution to resolve this issue. https://github.com/lepoco/wpfui/blob/303f0aefcd59a142bc681415dc4360a34a15f33d/src/Wpf.Ui/Controls/MessageBox/MessageBox.cs#L354-L362