Xamarin forms labs RadioButton control


Today, take RadioButton control as an example to introduce how xamarin forms labs is used in our project

XLabs is a open source project that aims to provide a powerful and
cross platform set of services and controls tailored to work with
Xamarin and Xamarin Forms. Xlabs is an open source project that provides cross platform services and controls for xamarin.

The GitHub address of xlabs is https://github.com/forrest23/Xamarin-Forms-Labs

  1. Download the project locally and use xamarin studio to open the project file xlabs SLN, and then compile. After successful compilation, there will be many DLL files in the build file. Create a new folder in your project and copy the DLL. Then add references to these DLLs in your main project, IOS project and Android project respectively.
    Xamarin forms labs RadioButton control

  2. Create a new forms and select contentpage XAML as the type
    Xamarin forms labs RadioButton control

  3. Add the following code to the XAML layout file to add a radiobuttongroup control
    <?xml version=”1.0″ encoding=”UTF-8″?>

       <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
                <StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand">
                    <control:BindableRadioGroup x:Name="ansPicker" SelectedIndex="{Binding ItemSelected}" TextColor="#70c7da" Orientation="Horizontal" HorizontalOptions="FillAndExpand"/>

    Note: xlabs can only be used when xmlns: control = “CLR namespace: xlabs. Forms. Controls; assembly = xlabs. Forms” is added Controls in forms.

  4. Yes xaml. CS file, add the following code to assign a value to itemssource of radiobuttongroup:

    public PatientSearch ()

               InitializeComponent ();
               this. Title = "search for patients";
               ansPicker.ItemsSource = new[]
                   "Inpatient number",
                   "Bed number",
               ansPicker.Items [0].WidthRequest = 80; 
               ansPicker.Items [1].WidthRequest = 100;
               ansPicker.Items [2].WidthRequest = 100;
               ansPicker.CheckedChanged += ansPicker_CheckedChanged;
               ansPicker.Items[0].Checked = true;


  5. This completes the introduction to the use of the xamarin forms labs RadioButton control.