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 に答える