MonoCode中是否有MessageBox.Show()equivelant

Dom*_*icz 5 .net monomac

MessageBox.Show()在MonoMac中是否有相同的内容,或者我是否必须专门为此目的创建某种弹出类?

Cur*_*tis 9

您正在寻找NSAlert,它与MessageBox大致相同.

您可以使用NSAlert.RunModal()显示NSAlert,或者如果希望它在特定窗口中显示为工作表,则使用NSAlert.BeginSheet().

例如

var alert = new NSAlert {
    MessageText = "Hello, this is an alert!",
    AlertStyle = NSAlertStyle.Informational
};

alert.AddButton ("OK");
alert.AddButton ("Cancel");

var returnValue = alert.RunModal();
// returnValue will be 1000 for OK, 1001 for Cancel
Run Code Online (Sandbox Code Playgroud)

您可以从MonoMac的角度看一下如何使用它:

https://github.com/picoe/Eto/blob/master/Source/Eto.Platform.Mac/Forms/MessageBoxHandler.cs