1

I am calling async method on demised of CustomMessageBox left button click. But its giving me complie time error. I googled for it but get some information regarding MessageDialog.Command. How I will achieve same in windows phone CustomMessageBox.

Here is my code

CustomMessageBox customMBox = new CustomMessageBox()
                {
                    Caption = "Alert!",
                    Message = string.Format("Clicking on clear all will clear all the data on the app. Are you sure you want to proceed?"),
                    LeftButtonContent = "Yes",
                    RightButtonContent = "No",
                };

                customMBox.Dismissed += (s2, e2) =>
                {
                    switch (e2.Result)
                    {
                        case CustomMessageBoxResult.LeftButton:
                            await clearDatabaseAsync();
                            break;
                        case CustomMessageBoxResult.RightButton:
                            break;
                        case CustomMessageBoxResult.None:
                            break;
                        default:
                            break;
                    }
                };

                customMBox.Show();

    public async Task clearDatabaseAsync()
    {
       //SQLite clear table record logic
        await App.DeleteDatabase();           

    }

can anyone please suggest me how I will achieve this?

Thanks in Advance.

Community
  • 1
  • 1
gofor.net
  • 4,218
  • 10
  • 43
  • 65

1 Answers1

4

Try like error says - use async lambda expression:

customMBox.Dismissed += async (s2, e2) => // rest of the code ...
Romasz
  • 29,662
  • 13
  • 79
  • 154