Forum Xamarin.Forms

Are there any samples with radio buttons?

VagifAbilovVagifAbilov NO ✭✭
edited June 2014 in Xamarin.Forms

Most of apps need some sort of selection buttons, but AFAIK Xamarin Forms don't offer XAML/C# support for radio buttons. Has anyone implemented such functionality in Xamarin.Forms projects for all three platforms? Does it require custom renderer? I am writing a very simple sample and didn't expect to get stuck at such simple UI elements. I would like my sample to stay minimalistic so I'd rather avoid writing much custom code, but I can't figure out how else I can implement radio and radio buttons.

A related question: what would be the best practice to include UI elements that don't have support in Xamarin.Forms XAML. Doing independent layouts for each platform is against Xamarin.Forms concept, so that's the recommended way to handle such scenarios in a cross-platform XAML?

Thanks in advance


  • Answering my own question. Having worked through examples I believe I better understand reasons for absence of cross-platform radio/check buttons. With no native support for them on all platforms developers should either use native looking Switch and Picker controls or implement their own choice of custom solution.

  • dannyg86dannyg86 IEMember

    @VagifAbilov‌ what were the reasons? I'm curious.


  • The main reason is that the controls like "radio button" or "check box" don't exist on each platform, so defining some control that would act like a check box on every platform would have to have a non-native look. This was Java applet approach which was disliked by both developers and users.

    Xamarin.Forms define Picker and Switch controls that look native and can be used to implement similar functionality. In case a developer wants a check box or radio group that would look like check boxes and radio buttons, he will need to add a custom control because there is no native check/radio controls on all platforms. I think this is something that can be added in a community-driven project (perhaps an idea for XForms project), but I find logical that such controls are not included in Xamarin.Forms.

  • dannyg86dannyg86 IEMember

    @VagifAbilov‌ Thanks for the explanation, makes sense.

  • Hi @VagifAbilov‌, @dannyg86‌ , I have created radio button and radio group custom renderer for android, in iOS its just looks like Radio button and completely native. working on Windows phone implementation.
    These are completely based on your requirement.

  • Cool! Thank you for your effort, @kirti. I will check it out.

  • Ranjith.7397Ranjith.7397 USUniversity ✭✭
    edited March 2015

    Hi Kirti. I have used your code it is working like charm. In my android app layout background is white. So when radio button is un-checked then it disappears because unchecked radio button color and layout background color is white. I trying to change the radio button color to green I dint get any clue for this. Please help me.

  • TektonTekton USMember ✭✭✭

    XLabs also contains radio buttons and checkboxes, although both of those controls seem a bit under-developed. Their BindableRadioGroup just uses strings to describe each radio button, but I found it more useful using the radio button control itself (cause I'm serializing/storing controls where I needed a radio button) [also made a BindableCheckboxGroup based on the RadioGroup]. In any case, their controls should work as-is for simple use cases. For my use case, I just ended up forking the project and modifying the controls how I needed them (and fixed an issue with default text color for the controls).

  • powerdudepowerdude USMember ✭✭

    Hey @Tekton, you should do a PR to get your changes back into XLabs. I'm sure they, and the community, would appreciate it

  • TektonTekton USMember ✭✭✭

    @cliftonvaughn Been planning on it, but I'm new to the PR stuff, so keep putting it off. I'll set aside some time this weekend to go through what I have and try to do the PR.

  • sid12sid12 INMember ✭✭

    any code for radio buttons in xamarin portable
    please help

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    @sid12 RadioButton it's not a XF control because it's not native in all platforms.

    You can take a look to some other implementations present in this page or in github

  • minkeyminkey INMember ✭✭

    hi @kirti I don't know how to get your code from GitHub

Sign In or Register to comment.