Where does DisplayAlert get the color used for the buttons?
Simply using DisplayAlert:
await DisplayAlert("Alert!", "This is DisplayAlert", "OK");
Is it possible to change this color on "OK"? It's also used in Picker and on Switch too.
You can get Latest Design Popup and Alert :https://github.com/rotorgames/Rg.Plugins.Popup
Different from Picker, Switch , DisplayAlert is not a rendered control in XF, we can't use custom renderer to customize it .
You could write DependencyService for custom Dialogs and use some custom layouts.
Refer the solution : https://forums.xamarin.com/discussion/comment/209602/#Comment_209602
Thanks for your replies.
@dinesh314850 That Popup plugin will come in useful for another project I have to do at a later date.
@ColeX That looked a bit too much to simply change a color, it wasn't really important so thought I would leave it.
But today I was looking into adding a SplashScreen and going through the Xamarin docs, one step was to add to the Resources/values/styles.xml file.
In there I spotted an item called colorAccent
Changing this does what I need, it changes the OK/Cancel buttons on DisplayAlert, the color on a Switch control, and also the color for the Entry field the cursor is in.
in Xamarin.Forms projet and iOS part it can be simply set in Main.cs by Appearance:
UIView.AppearanceWhenContainedIn(typeof(UIAlertView)).TintColor = UIColor.Red;
UIView.AppearanceWhenContainedIn(typeof(UIAlertController)).TintColor = UIColor.Red;
In Android part of Xamarin.Forms it can be set by styles - in Resources/values/styles.xml set colorAccent
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
Xamarin Inc., as a wholly-owned Microsoft subsidiary acting as a separate legal entity, adheres to the Microsoft Privacy Statement: Privacy & cookies