mauicontentviewdisplayalert

How can you DisplayAlert from a .NET Maui ContentView?


I am trying to do something similar to:

await DisplayAlert("Alert", "You have been alerted", "OK");

The issue is the button that is triggering this is on a ContentView, not a ContentPage. I understand why it is not available on the view (sort of), but there must be a way to trigger an alert dialogue if your UI object is part of a view I would think.

Any ideas?

Thanks.


Solution

  • Use

    App.Current.Mainpage.DisplayAlert(…);