WPF消息框显示错误消息

San*_*osh 4 c# wpf messagebox

我正在开发WPF应用程序,并且想要显示带有诸如信息或问题之类符号的消息框。我写了这段代码:

MessageBox.Show("Added Sucessfully","Alert",MessageBoxImage.Information);
Run Code Online (Sandbox Code Playgroud)

但显示错误/红线

错误:system.windows.messagebox.show(string,string,messageboximage)有一些无效的参数

Yev*_*niy 5

你错过了MessageBoxButton争论。请尝试以下操作:

MessageBox.Show("Added successfully", "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
Run Code Online (Sandbox Code Playgroud)

确保您使用的MessageBox不是System.Windows命名空间,而是使用命名空间System.Windows.Forms