Open maslewandowski opened 2 months ago
You need to set the owner of the window first
Like this:
var uiMessageBox = new Wpf.Ui.Controls.MessageBox
{
Title = "test",
Content = "test",
WindowStartupLocation = WindowStartupLocation.CenterOwner
};
uiMessageBox.Owner = Application.Current.MainWindow;
await uiMessageBox.ShowDialogAsync();
@maslewandowski Does that fix your issue? If yeas, please close this issue.
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();
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
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
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