7

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

Nacimota
  • 22,395
  • 6
  • 42
  • 44
Santhosh
  • 107
  • 1
  • 3
  • 11

2 Answers2

14

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.

Yevgeniy
  • 1,054
  • 1
  • 9
  • 17
-1

you can get back the result from message box and check your condition as :

MessageBoxResult result = MessageBox.Show("Added successfully", "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
            if (result == MessageBoxResult.OK)
            {

            }
Aqib Murtaza
  • 17
  • 1
  • 5
  • The OP wants to show the message symbol. Not check for message result. Also, your first line in the code is same as the above answer. – ElectricRouge Jan 13 '23 at 09:47