Xamarin Forms: Show Confirm Popup Window

11/3/2016 2:53:50 PM

The following will create a Xamarin Forms button that will show a popup confirm dialog and handle the user's input.

<!-- in XAML File -->
<Button Text="Clear"             
              Clicked="butClear_onClick"
></Button>

//C# XAML File Code Behind
async void butClear_onClick(object sender, EventArgs e)
{
	var confirmed = await DisplayAlert("Confirm", "Are you sure?", "Yes", "No");
	if (confirmed)
	{
		//add code for the "Yes" logic
	}
	else
	{
		//add code for the "No" logic
	}            
}