1

我在CustomMessageBox左键单击终止时调用异步方法。但它给了我编译时间错误。我搜索了它,但得到了一些关于MessageDialog.Command的信息。我将如何在 windows phone 中实现相同的目标CustomMessageBox

这是我的代码

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();           

    }

谁能建议我如何实现这一目标?

提前致谢。

4

1 回答 1

4

尝试像错误说 - 使用async lambda expression

customMBox.Dismissed += async (s2, e2) => // rest of the code ...
于 2014-05-29T14:04:28.377 回答