

Sometimes an application enters a state where a CheckBox being checked is not a valid operation. In the following screenshots, the iOS screenshot shows the Label formatting when the CheckBox is empty, while the Android screenshot shows the Label formatting when the CheckBox is checked:įor more information about triggers, see Xamarin.Forms Triggers. When the IsChecked property returns to false, the FontAttributes and FontSize properties of the Label are reset to their initial state. When this property becomes true, the FontAttributes and FontSize properties of the Label change. In this example, the Label uses a binding expression in a data trigger to monitor the IsChecked property of the CheckBox. The CheckedChanged event handler can be eliminated by using data binding and triggers to respond to a CheckBox being checked or empty: Perform required operation after examining e.Value The CheckBox can be checked by user manipulation, or by setting the IsChecked property to true: Īlternatively, a CheckBox can be created in code: CheckBox checkBox = new CheckBox ĬheckBox.CheckedChanged += (sender, e) => This XAML results in the appearance shown in the following screenshots:īy default, the CheckBox is empty.

The following example shows how to instantiate a CheckBox in XAML: When the event is fired, the value of the Value property is set to the new value of the IsChecked property. The CheckedChangedEventArgs object that accompanies the CheckedChanged event has a single property named Value, of type bool. The IsChecked bindable property has a default binding mode of BindingMode.TwoWay.ĬheckBox defines a CheckedChanged event that's fired when the IsChecked property changes, either through user manipulation or when an application sets the IsChecked property.
