我有这个代码,我缩短了这个问题:
resetButton.Clicked += async (sender, e) =>
{
var response = await X.DisplayAlert("X","Y","Yes", "No");
};
我想将其分解为一种方法,所以我尝试了这个:
resetButton.Clicked += resetButtonClicked;
protected void resetButtonClicked(object sender, EventArgs e)
{
var response = await X.DisplayAlert("X","Y","Yes", "No");
}
但这不起作用,因为我需要指定方法为异步。有人可以给我一些建议吗?
答案 0 :(得分:1)
这项工作。
resetButton.Clicked += resetButtonClicked;
protected async Task resetButtonClicked(object sender, EventArgs e)
{
var response = await X.DisplayAlert("X","Y","Yes", "No");
}