我使用了developer.xamarin网站的代码,但它不起作用,我想我错过了一些“使用”文件。
var alertButton2 = new Button { Text = "DisplayAlert Yes/No" }; // trigger alert
alertButton2.Clicked += async (sender, e) => {
var answer = await DisplayAlert ("Question?", "Would you like to play a game", "Yes", "No");
Debug.WriteLine("Answer: " + answer); // writes true or false to the console
感谢所有答案。