Skip to main content
Logo Appt Light

Accessibility dialog on Xamarin

A dialog overlays the screen and offers one or more actions to proceed. Dialogs should always include a close button to make them accessible for users of assistive technologies. Furthermore, the focus of assistive technologies should be trapped inside the dialog while it's visible.

In Xamarin Forms you can use the DisplayAlert method to show an alert. The last parameter of the method is the text of cancel button and it is required to supply it. Therefore, a cancel button is always shown! The focus of assistive technologies is automatically trapped inside the dialog while it's visible.

var accept = await App.Current.MainPage.DisplayAlert(
  "Confirm Appt membership?", 
  "Your bank account will be billed.",
  "Proceed",
  "Cancel"
);

if (accept) {
    // Proceed
} else {
    // Cancel
}

Feedback?

Let us know!