How to change Display Alert default focus on a button?

1.2k views Asked by At

I am using Xamarin forms DisplayAlert. I have two buttons in it one is light blue and another is Darker blue. I guess it is focus effect causing the difference. can I set focus as per requirement? I tried to search documentation but no luck.

 DisplayAlert("Caption", "Message", "Cancel", "Send");

Cancel and send are buttons on display alert. Default focus on Cancel.I want to switch focus to Send without changing position of buttons.

1

There are 1 answers

0
Demitrian On BEST ANSWER

I am pretty sure that Xamarin doesn't (and will not) support providing focus to a specific button using a DisplayAlert since this feature exists in iOS only. Remember that Xamarin.Forms is meant to target all platforms, and not iOS only, and introducing a "focus" variable for a single platform would thus be a no-go.

What you can do, is to swap your two buttons around as you mentioned yourself.

If that is not an option, have a look at what you can achieve using third party libraries such as Acr.UserDialogs.

If that doesn't help you either, you will probably need to write a Custom Control or use an ActionSheet instead.

Good luck.