Hello,
Welcome to Microsoft Q&A!
The error shows that we should use OnPlatform inside the RadioButton.Content tag , and specify the actual type as x:TypeArguments.
Please refer to official sample code .
---
First I tried with type x:String and x:Object get the following result
<RadioButton >
<RadioButton.Content>
<OnPlatform x:TypeArguments="x:String">
<On Platform="iOS" Value="Apple" />
<On Platform="Android, UWP" Value="Google" />
</OnPlatform>
</RadioButton.Content>
</RadioButton>
<RadioButton >
<RadioButton.Content>
<OnPlatform x:TypeArguments="x:Object">
<On Platform="iOS" Value="Apple" />
<On Platform="Android, UWP" Value="Google" />
</OnPlatform>
</RadioButton.Content>
</RadioButton>
---
Then I following the way provided by docs but still no luck
xmlns:sys="clr-namespace:System;assembly=mscorlib"
<RadioButton >
<RadioButton.Content>
<OnPlatform x:TypeArguments="sys:String"> //sys:Object does not work either
<On Platform="iOS" Value="Apple" />
<On Platform="Android, UWP" Value="Google" />
</OnPlatform>
</RadioButton.Content>
</RadioButton>
---
Xamarin.Forms 5.0 defines the type of RadioButton.Content as object not string , maybe it is the cause.
I'm afraid we have to use Binding .
public string myContent {
get
{
if (Device.RuntimePlatform == Device.iOS)
return "Apple";
else if (Device.RuntimePlatform == Device.UWP | Device.RuntimePlatform == Device.Android)
return "Google";
return "";
}
}
<RadioButton Content="{Binding myContent}" />
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.