MessageBox.Avalonia
MessageBox.Avalonia copied to clipboard
CenterScreen can show messageBox in CenterScreen.
Operator System:Ubuntu 21.10
I use this code to show a dialog,WindowStartupLocaiton
property used CenterSceen
,but this dialog show on the left corner.
wait MessageBoxManager.GetMessageBoxStandardWindow(new MessageBoxStandardParams
{
ButtonDefinitions = ButtonEnum.OkCancel,
ContentTitle = title,
ContentMessage = msg,
Icon = Icon.Error,
WindowStartupLocation = WindowStartupLocation.CenterScreen,
Topmost = true
}).Show();
Does center screen works in ur os with clear windows? Just create avalonia window and setup center screen.
I use these following code,but all of them can not show in CenterScreen.
await MessageBoxManager.GetMessageBoxStandardWindow(new MessageBoxStandardParams
{
ButtonDefinitions = ButtonEnum.OkCancel,
ContentTitle = title,
ContentMessage = msg,
Icon = Icon.Error,
WindowStartupLocation = WindowStartupLocation.CenterScreen,
Topmost = true
}).ShowDialog(new Window {WindowStartupLocation = WindowStartupLocation.CenterScreen,IsVisible = true});
var tempWindow= new Window { WindowStartupLocation = WindowStartupLocation.CenterScreen};
tempWindow.Show();
await MessageBoxManager.GetMessageBoxStandardWindow(new MessageBoxStandardParams
{
ButtonDefinitions = ButtonEnum.OkCancel,
ContentTitle = title,
ContentMessage = msg,
Icon = Icon.Error,
WindowStartupLocation = WindowStartupLocation.CenterScreen,
Topmost = true
}).ShowDialog(tempWindow);
I have the same issue, the message box always shows up at the top left of the current monitor. Also If I try to get the message box to actually popup on top of the window it should like this:
var messageBox = MessageBox.Avalonia.MessageBoxManager.GetMessageBoxStandardWindow("Extraction finished",
$"Extraction to folder {result} finished", ButtonEnum.Ok, MessageBox.Avalonia.Enums.Icon.None,
WindowStartupLocation.CenterOwner);
await messageBox.ShowDialog(this);
It still refuses to appear anywhere else except the top left corner of my monitor.
Edit: reading other issues I remembered that this was already reported in the bunch of linux issues here: https://github.com/AvaloniaCommunity/MessageBox.Avalonia/issues/88
Suspect it might have something to do with this:
https://github.com/AvaloniaUI/Avalonia/pull/9674
Hopefully fixed in near future, otherwise you need a kludge fix to centre the window on Linux.
It's avalonia problem(