2

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?

4

1 回答 1

2

不幸的是,除了显示的文本和按钮之外,您根本无法自定义 a MessageDialog

我认为最简单的解决方案是创建自己的IDialogService,这将是PCLwithDisplayDialog方法中的接口。此方法将具有与该方法相同的参数Xamarin.Forms DisplayAlert

现在,您将在每个平台上提供此接口的实现。在 Android 和 iOS 的情况下,我想您希望保持当前行为不变,因此该DisplayDialog方法的实现可以直接调用 Xamarin DisplayAlert,只需传递参数。

在 Windows 的情况下,您可以显示您的自定义ContentDialog.

Xamarin 文档中提供了编写平台特定服务的示例。

于 2016-11-23T08:26:15.140 回答