I'm completely new to xamarin.forms, I need to add a checkbox, radio buttons and drop down list. I tried some samples from net but I'm not able to get the checkbox. Can anyone help me to achieve this in xamarin.forms?
Xaml file
<toolkit:CheckBox Text ="Employee"
FontSize="20"
CheckedChanged ="OnClicked"/>
or
<controls:CheckBox DefaultText="Default text"
HorizontalOptions="FillAndExpand"
TextColor="Green"
FontSize="25"
FontName="AmericanTypewriter"/>
Some links or sample code will make it easier to understand.
Based on Kasper Answers, but using the image instead of a button so that it will not show the shadow.
I implemented the checkbox and dropdown in the .cs file of xamarin cross platform.I suggest you use cs files for creating the UI.Xamarin is providing the leverage to use any one of the feature either cs file or AXML file to create the UI
You need to add the Nuget package called Xlabs.form. Try to import it in your Xaml.cs file like:
In addition, you also have to add the following line in your .cs file:
In Xaml it is different:
Or you can use
<controls:checkbox>
.Note: Don't forget to add the below line in the Contentpage of Xaml:
I found a better way to do this which is to create your own. It was really quite simple. Create a cs file in a Resources project (or where ever you want) called CheckBox and paste this code:
There is probably a better way to do this but I just added the two images to the appropriate locations in each project (base for UWP, Resources/Drawable for Android).
Then to use it in your Xaml just do something like this (I used a converter bc I was binding to a string value):
Note: You must set the BindingContext in your pages cs file for the check to work. So your Pages code behind file should look like this:
And this is the result!
Hope this helps someone!!
UPDATE:
The following is new code that removes the gray background on disabled and also allows text to wrap if it does not fit on the screen. This uses a ContentView that contains a grid that can expand based on the content.