我在调用CustomMessageBox
左键单击时调用异步方法。但它给了我complie时间错误。我搜索了它,但获得了有关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();
}
任何人都可以建议我如何实现这一目标吗?
先谢谢。
答案 0 :(得分:4)
尝试错误说 - 使用async lambda expression
:
customMBox.Dismissed += async (s2, e2) => // rest of the code ...