I'm using the DisplayAlert()
method in Xamarin.Forms. Internally it uses MessageDialog
.
How can I change the style of the ok and cancel button on different events like PointerOver
, Pressed
, and so on?
Here one does implement it's own ContentDialog
with the according style. Other try to override some brushes, with the disadvantage that other things are changed too.
Has anyone got it managed to override the style/control template only for a MessageDialog
?
Unfortunately, apart from the displayed text and buttons you can't customize a MessageDialog
at all.
I think the simplest solution would be to create your own IDialogService
, that would be an interface in the PCL
with a DisplayDialog
method. This method would have the same parameters as the Xamarin.Forms
DisplayAlert
method.
Now you would provide an implementation of this interface on each platform. In case of Android and iOS I suppose you want to keep the current behavior intact, so the implementation of the DisplayDialog
method could just call Xamarin's DisplayAlert
directly, just passing the arguments.
In case of Windows, you could then display your custom ContentDialog
.
An example of writing platform specific services is available in Xamarin Documentation.