I'm using DisplayAlert in my Xamarin.Forms project to display a popup to warn the user before preceding with an action. This is the two button form of DisplayAlert, which is defined like this:
public System.Threading.Tasks.Task<bool> DisplayAlert (string title, string message, string accept, string cancel);
Unfortunately on iOS, the "cancel" string on the popup is in bold instead of the "accept" string. Here is some really basic code that I put together to reproduce the error.
MainPage.xaml:
<StackLayout>
<Button x:Name="TheButton" Text="Test DisplayAlert" HorizontalOptions="Center" VerticalOptions="CenterAndExpand" Pressed="Handle_Pressed"/>
</StackLayout>
MainPage.xaml.cs
using System;
using Xamarin.Forms;
namespace DisplayAlertText
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
int colorIndex = 0;
async void Handle_Pressed(object sender, System.EventArgs e)
{
var action = await DisplayAlert("Popup", "Change text color?", "Yes", "No");
if (action)
{
colorIndex++;
if (colorIndex == 5)
colorIndex = 0;
Color newColor;
switch (colorIndex)
{
case 0:
newColor = Color.Black;
break;
case 1:
newColor = Color.Red;
break;
case 2:
newColor = Color.Yellow;
break;
case 3:
newColor = Color.Green;
break;
case 4:
newColor = Color.Blue;
break;
default:
newColor = Color.PeachPuff;
break;
}
TheButton.TextColor = newColor;
}
}
}
}
This has the "No" option in bold (I would post a screenshot but I don't seem to be allowed to). This is not the bolding strategy that Apple uses. The "Yes" option should be in bold. You can also see the Microsoft Xamarin example for DisplayAlerts even has the "Accept" button in bold like is supposed to be the case (I can't post links, but you will see if you look at the example on their website). Any help would be appreciated. Thanks!