How to use xamarin radio buttons

When creating the registration page, I need to get the following data from the user. -Name -Surname -username -El. Address -Password -Date of Birth - Gender - User Role

For the last parameters, I can not find how to use radio buttons in xamarin formats. Below 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>
+3
source share
7 answers

If you want real radio buttons, you can put their package ( https://github.com/XLabs/Xamarin-Forms-Labs/tree/master/src/Forms/XLabs.Forms/Controls/RadioButton )

, Xlabs , radioobutton

+1

XLabs NuGets. : Xaml : BindableRadioGroup x: Name= "Radiobtn" Cs string [] gender = { "MAlE", "FEMALE" } Radiobtn.Add()

https://github.com/XLabs/Xamarin-Forms-Labs/tree/master/samples/XLabs.Samples/XLabs.Samples/Pages/Controls

+1

. , . . xaml:

<Image  Scale="0.7"  HorizontalOptions="Start" x:Name="radioButton" Source="unRadioBtn.png">
                    <Image.GestureRecognizers>
                        <TapGestureRecognizer Tapped="radioButton_Clicked"></TapGestureRecognizer>
                    </Image.GestureRecognizers>
                </Image>

.cs:

 private void radioButton_Clicked(object sender, EventArgs e)
    {
        radioButton.Source = "radioBtn.png";
    }
0

. checkbox XLabs, , .

: .

0

Xamarin Radio.

1) Switch

2) Picker

0
0

XLabs RadioButton and BindableRadioGroup work well: XLabs RadioButton for Xamarin forms

Here's a simple Yes / No radio using the BindableRadioGroup:

var answers = new List<string>();
answers.Add("Yes");
answers.Add("No");

var RadioGroup = new XLabs.Forms.Controls.BindableRadioGroup()
{
  ItemsSource = answers, 
  Orientation = StackOrientation.Horizontal
};
0
source

All Articles