Please be aware that I no longer mantain this project, you should use the Forms.Controls instead
A really simple implementation of a Checkbox control for Xamarin.Forms. Basically a stripped down version of XLabs' Checkbox mixed with Marxon13's M13Checkbox.
Steps:
Remember to install the package in ALL your platform specific projects
Make sure to call CheckboxRenderer.Init();
right after Xamarin.Forms.Init();
in your projects. Look a tht AppDelegate.cs
code snippet from the sample app:
global::Xamarin.Forms.Forms.Init();
CheckboxRenderer.Init();
var cb1 = new Checkbox() { WidthRequest = 55 };
var cb2 = new Checkbox() { WidthRequest = 45, IsEnabled = false };
var cb3 = new Checkbox() { WidthRequest = 35, Checked = true };
var cb4 = new Checkbox();
The checkbox is meant to be of an square shape, so to control the size of the checkbox please set only WidthRequest.
cb1.CheckedChanged +=
(sender, e) =>
{
cb2.IsEnabled = e.IsChecked;
cb3.Checked = !cb1.Checked;
};
First, pull in the namespace:
xmlns:m16="clr-namespace:Messier16.Forms.Controls;assembly=Messier16.Forms.Controls.Checkbox"
Then, use it
<m16:Checkbox WidthRequest="55" Checked="{Binding Check1}"></m16:Checkbox>
<m16:Checkbox WidthRequest="45" Checked="{Binding Check2}" IsEnabled="{Binding Check1}"></m16:Checkbox>
<m16:Checkbox WidthRequest="35" Checked="{Binding Check1, Mode=OneWay, Converter={StaticResource BoolInverter}}" ></m16:Checkbox>
<m16:Checkbox IsVisible="{Binding Check2}"></m16:Checkbox>
As you can see, the Checked
property is bindable.