Home > Mobile >  Xamarin RadioButton.Content not showing correct content
Xamarin RadioButton.Content not showing correct content

Time:02-24

I'm trying to set an image inside a RadioButton like shown at https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/radiobutton

<RadioButton>
    <RadioButton.Content>
        <Image Source="icon.png"/>
    </RadioButton.Content>
</RadioButton>

But in app it shows only the text "Xamarin.Forms.Image" instead of the image.

What is wrong? I just did it like in the example.

CodePudding user response:

Please read the docs

However, on some platforms a RadioButton can display a View,

and

On Android, RadioButton objects will display a string-based representation of the View object that's been set as content:

CodePudding user response:

Can you please try it this way.

<RadioButton Value="test">
            <RadioButton.Content>
                <StackLayout>
                    <Image Source="icon.png"
                           HorizontalOptions="Center"
                           VerticalOptions="CenterAndExpand" />
                    <Label Text="test"
                           HorizontalOptions="Center"
                           VerticalOptions="End" />
                </StackLayout>
            </RadioButton.Content>
        </RadioButton>
  • Related