Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use radio buttons in xamarin forms

Creating a Registration page, I need to get the following data from user.

  • First Name
  • Last Name
  • Username
  • Email
  • Password
  • Date of Birth
  • Gender
  • User Role

For the last two parameters, I am unable to find how to use radio buttons in Xamarin.Forms. Following is my code for the Registration Page.

<StackLayout BackgroundColor="#30af91" Padding="60">


<Entry Text="{Binding FirstName}" Placeholder="First Name"/>
<Entry Text="{Binding LastName}" Placeholder="Last Name"/>
<Entry Text="{Binding UserName}" Placeholder="Last Name"/>
<Entry Text="{Binding Email}" Placeholder="Email" />
<Entry Text="{Binding Password}" Placeholder="Password" IsPassword="True"/>
<Entry Text="{Binding ConfirmPassword}" Placeholder="Confirm Password" IsPassword="True"/>
<DatePicker MinimumDate="1/1/1948" MaximumDate="12/31/2007"/>


<!--Radio buttons for Gender
    1. Male   2.Female-->

<!--Radio Buttons for UserRole
    1. Admin  2.Participant-->

<Button Command="{Binding RegisterCommand}" Text="Register"/>
<Label Text="{Binding Message}" />


</StackLayout>
like image 353
Uzair Nadeem Avatar asked May 23 '17 19:05

Uzair Nadeem


2 Answers

Xamarin forms does not provide Radio Button.

You can either use

1)Switch

2)Picker

or any other component to fulfill your requirement

UPDATE

The xamarin forms update version 4.6 has introduced the Radio button control, Here is the official documentation

like image 136
Dinesh Phalwadiya Avatar answered Sep 28 '22 16:09

Dinesh Phalwadiya


Xamarin.Forms 4.6 introduced a new RadioButton control. You can find the documentation here: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/radiobutton

like image 39
jfmg Avatar answered Sep 28 '22 15:09

jfmg