

To get a response from an alert, supply text for both buttons and await the method: bool answer = await DisplayAlert("Question?", "Would you like to play a game", "Yes", "No") Īfter the user selects one of the options the response will be returned as a bool. The DisplayAlert method can also be used to capture a user's response by presenting two buttons and returning a bool. The alert is displayed modally, and once dismissed the user continues interacting with the app:

The following example shows a simple message to the user: await DisplayAlert("Alert", "You have been alerted", "OK") To display alerts, use the DisplayAlert method on any Page. NET MAUI-supported platforms have a modal pop-up to alert the user or ask simple questions of them. Pop-ups are rendered with native controls on each platform. Displaying an alert, asking a user to make a choice, or displaying a prompt is a common UI task.NET Multi-platform App UI (.NET MAUI) has three methods on the Page class for interacting with the user via a pop-up: DisplayAlert, DisplayActionSheet, and DisplayPromptAsync.
