MessageBox.Avalonia icon indicating copy to clipboard operation
MessageBox.Avalonia copied to clipboard

CenterScreen can show messageBox in CenterScreen.

Open SinnoSong opened this issue 1 year ago • 3 comments

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

image

SinnoSong avatar Jul 28 '22 08:07 SinnoSong

Does center screen works in ur os with clear windows? Just create avalonia window and setup center screen.

CreateLab avatar Jul 28 '22 12:07 CreateLab

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

SinnoSong avatar Jul 29 '22 02:07 SinnoSong

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

hhyyrylainen avatar Jul 31 '22 14:07 hhyyrylainen

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.

kuiperzone avatar Dec 23 '22 05:12 kuiperzone

It's avalonia problem(

CreateLab avatar Feb 13 '23 13:02 CreateLab