Xamarin Tips: Xamarin Forms Checkbox
There are no checkbox controls in Xamarin Forms. You can build the custom components with the custom renderers for this purpose. That is very complex. I chose to use a simpler way, using an Image control and TapGestureRecognizer. If the image is checked, then print the checked image, otherwise, just print an empty square. That is easy.
Code
this.chkbox.GestureRecognizers.Add(new TapGestureRecognizer | |
{ | |
TappedCallback = (v, o) => | |
{ | |
if (!checked) | |
{ | |
chkbox.source = ImageSource.FromFile("checked.png"); | |
checked = true; | |
} else{ | |
chkbox.source = ImageSource.FromFile("unchecked.png"); | |
checked =false; | |
} | |
} |
Trackback address for this post
Trackback URL (right click and copy shortcut/link location)
Feedback awaiting moderation
This post has 245 feedbacks awaiting moderation...
Form is loading...