Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Messagebox shows Error message

Tags:

c#

wpf

messagebox

I'm developing a WPF application and I want to show message box with symbol like information or question. I have written this code:

MessageBox.Show("Added Sucessfully","Alert",MessageBoxImage.Information);

but it shows an error/red line:

Error:system.windows.messagebox.show(string,string,messageboximage) has some invalid arguments

like image 358
Santhosh Avatar asked May 12 '17 12:05

Santhosh


People also ask

How to style message box in WPF?

Then you have to compile your solution with this app. manifest (set it in the project properties -> Application -> Point to the new manifest in "Icons and manifest"). If you start your application now it should look like the WinForms- MessageBox. Thanks for the answer.

What is the namespace for MessageBox in C#?

There is no such namespace System. Forms , the class you were trying to use ( MessageBox ) is in System. Windows.


1 Answers

You have missed the MessageBoxButton argument. Try the following:

MessageBox.Show("Added successfully", "Alert", MessageBoxButton.OK, MessageBoxImage.Information);

Make sure you are using MessageBox from System.Windows namespace, not System.Windows.Forms.

like image 56
Yevgeniy Avatar answered Oct 06 '22 16:10

Yevgeniy