How can I create a custom alert pop-up in .NET MAUI?

Platform: .NET MAUI| Category: Controls

A custom alert pop-up can be created by defining a separate pop-up page or view that includes the message you want to display as well as an OK button for dismissal. Here’s a simple example:

XAML

<VerticalStackLayout VerticalOptions="Center">
        <Button Text="Navigate to DetailsPage"
                Clicked="Button_Clicked" />
</VerticalStackLayout>

C#

private async void Button_Clicked(object sender, EventArgs e)
    {
        await DisplayAlert("Navigation Alert", "Navigate to next page", "OK");
        await Navigation.PushAsync(new DetailsPage());
    }

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.