Skip to content

CheckBox

Enis Necipoglu edited this page Jul 2, 2018 · 10 revisions

Type


Xamarin Forms CheckBox Background Color
      <input:CheckBox Text="Option 1" Type="Box"   IsChecked="True" />
      <input:CheckBox Text="Option 1" Type="Check" IsChecked="True" />
      <input:CheckBox Text="Option 1" Type="Cross" IsChecked="True" />
      <input:CheckBox Text="Option 1" Type="Star"  IsChecked="True" />

There are 4 Types for CheckBox. Box is default Type.







IsChecked


Xamarin Forms CheckBox IsChecked
            <input:CheckBox Text="Consetetur eum kasd eos" IsChecked="False" />
Xamarin Forms CheckBox IsChecked
            <input:CheckBox Text="Hello World I'm Option 2" IsChecked="True" />

Binding: This have Two-Way Binding also.

            <input:CheckBox Text="Hello World I'm Option 2" IsChecked="{Binding YourProperty}" />

You can set it from your ViewModel or it'll change your ViewModel's property when user checked.







Key


  <input:CheckBox Text="Hello I'm Option 1" Key="1" />
  <input:CheckBox Text="Hello I'm Option 2" Key="2" />

Key just a **Int32 **value to keep inside of CheckBox, You can keep Id or something else inside it.

Binding: This have Two-Way Binding also.

  <input:CheckBox Text="I'm Option 1" Key="{Binding YourFirstProperty}" />
  <input:CheckBox Text="I'm Option 2" Key="{Binding YourSecondProperty}" />

This property is One-Way Binding property.It can't be changed at runtime by user. This is only have Source to View Binding.







BoxBackgroundColor


Xamarin Forms CheckBox Background Color
   <input:CheckBox BoxBackgroundColor="Aqua" IsChecked="True" Text="Option 1"/>

Allows to change box's background of CheckBox

Binding: This have One-Way Binding also.

   <input:CheckBox BoxBackgroundColor="{Binding YourColor}" IsChecked="True" Text="Option 1"/>
   <!-- OR -->
   <!--YOU CAN USE DYNAMICRESOURCE FROM APP.XAML-->
   <input:CheckBox BoxBackgroundColor="{DynamicResource YourColor}" IsChecked="True" Text="Option 1"/>






Color


Xamarin Forms CheckBox Background Color
   <input:CheckBox Color="Blue" IsChecked="True" Text="Option 2"/>

Allows to change Checked icon color of CheckBox

Binding: This have One-Way Binding also.

   <input:CheckBox Color="{Binding YourColor}" IsChecked="True" Text="Option 2"/>
   <!-- OR -->
   <!--YOU CAN USE DYNAMICRESOURCE FROM APP.XAML-->
   <input:CheckBox Color="{DynamicResource YourColor}" IsChecked="True" Text="Option 2"/>






TextColor


Xamarin Forms CheckBox Background Color
   <input:CheckBox TextColor="Purple" Text="Option"/>

Binding: This have One-Way Binding also.

   <input:CheckBox TextColor="{Binding YourColor}" Text="Option"/>
   <!-- OR -->
   <!--YOU CAN USE DYNAMICRESOURCE FROM APP.XAML-->
   <input:CheckBox TextColor="{DynamicResource YourColor}" Text="Option"/>






TextFontSize


Xamarin Forms CheckBox Background Color
   <input:CheckBox TextFontSize="30" Text="Option" />

Binding: This have One-Way Binding also.

   <input:CheckBox TextFontSize="{Binding YourSize}" Text="Option"/>






BoxSizeRequest


Xamarin Forms CheckBox Background Color
   <input:CheckBox BoxSizeRequest="100" Text="Option"/>

Binding: This have One-Way Binding also.

   <input:CheckBox BoxSizeRequest="{Binding YourSize}" Text="Option"/>






IsDisabled


Xamarin Forms CheckBox Background Color
   <input:CheckBox IsDisabled="true" Text="Option 1"/>
   <input:CheckBox IsDisabled="true" Text="Option 1" IsChecked="True"/>

Disables the checkbox. Opacity will be 0.6 and user can not interact with it.

Binding: This have One-Way Binding also.

   <input:CheckBox IsDisabled="{Binding YourBooleanProperty}" Text="Option 1"/>

Clone this wiki locally