我正在开发一个WPF应用程序,我想显示带有信息或问题符号的消息框。我已经编写了以下代码:
MessageBox.Show("Added Sucessfully","Alert",MessageBoxImage.Information);
但它显示了一个错误/红线:
错误:system.windows.messagebox.show(string,string,messageboximage)有一些无效的参数
我正在开发一个WPF应用程序,我想显示带有信息或问题符号的消息框。我已经编写了以下代码:
MessageBox.Show("Added Sucessfully","Alert",MessageBoxImage.Information);
但它显示了一个错误/红线:
错误:system.windows.messagebox.show(string,string,messageboximage)有一些无效的参数
您错过了MessageBoxButton
参数。请尝试以下操作:
MessageBox.Show("Added successfully", "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
请确保您使用的是 System.Windows
命名空间中的 MessageBox
,而不是 System.Windows.Forms
。
你可以从消息框中获取结果并检查你的条件,如下:
MessageBoxResult result = MessageBox.Show("Added successfully", "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
if (result == MessageBoxResult.OK)
{
}