MonoMac中是否有等效的MessageBox.Show()
,还是我必须为此专门创建某种弹出类?
最佳答案
您正在寻找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
您可以从MonoMac的角度看一下如何使用它:
https://github.com/picoe/Eto/blob/master/Source/Eto.Platform.Mac/Forms/MessageBoxHandler.cs
关于.net - 在UniCode中是否有一个MessageBox.Show()等效项,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10524919/