wpfui icon indicating copy to clipboard operation
wpfui copied to clipboard

MessageBox WindowStartupLocation does not work

Open maslewandowski opened this issue 1 year ago • 5 comments

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

maslewandowski avatar Apr 10 '24 09:04 maslewandowski

You need to set the owner of the window first

SlimeNull avatar Apr 14 '24 10:04 SlimeNull

Like this:

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

SlimeNull avatar Apr 14 '24 10:04 SlimeNull

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

m0lDaViA avatar May 08 '24 12:05 m0lDaViA

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();

FaisalMangattil avatar May 29 '24 11:05 FaisalMangattil

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

textGamex avatar Jun 13 '24 09:06 textGamex