Search code examples
c#wpfmessagebox

WPF Messagebox shows Error message


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


Solution

  • 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.