Message on Exit Button - Xamarin Forms

-1

I need a message on the Exit Button (I will use Navigation.PopAsync() ) next to what I did but it works (it does not work):

//Botão Sair
void BtnSair_Clicked(object sender, EventArgs e)
{
   var result = DisplayAlert("Alerta", "Deseja realmente sair?", "Sim", "Não");
   if (result) {Navigation.PopAsync();}  
}
    
asked by anonymous 25.05.2018 / 16:10

1 answer

0

As some might be useful I was able to solve it like this:

private async Task BtnSair_Clicked(object sender, EventArgs e)
{
  var result = await DisplayAlert("Alerta", "Deseja realmente sair?", "Sim", "Não");

  if (result)
  {
    await Navigation.PopAsync();
  }
}

I noticed that DisplayAlert returns Task and the variable expected only bool , so in the button call I used private async Task and then await where you have to wait for return.

    
25.05.2018 / 19:24