From 51147d096a8dc5bda673b3b8c91dacd5ebf5cb70 Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Sat, 17 Sep 2022 16:37:33 +0300 Subject: [PATCH] Convert Type property of CheckBox to BindableProperty --- src/InputKit.Maui/Shared/Controls/CheckBox.cs | 6 ++++-- .../Shared/Controls/CheckBox.cs | 11 ++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/InputKit.Maui/Shared/Controls/CheckBox.cs b/src/InputKit.Maui/Shared/Controls/CheckBox.cs index 28b2a1b..96db069 100644 --- a/src/InputKit.Maui/Shared/Controls/CheckBox.cs +++ b/src/InputKit.Maui/Shared/Controls/CheckBox.cs @@ -66,7 +66,6 @@ public partial class CheckBox : StatefulStackLayout, IValidatable protected Lazy iconValidation; - private CheckType _type = CheckType.Regular; private bool _isEnabled; #endregion @@ -201,7 +200,7 @@ public Color Color /// /// Which icon will be shown when checkbox is checked /// - public CheckType Type { get => _type; set { _type = value; UpdateType(); } } + public CheckType Type { get => (CheckType)GetValue(TypeProperty); set => SetValue(TypeProperty, value); } /// /// Size of Checkbox @@ -330,6 +329,9 @@ public void DisplayValidation() checkBox.iconValidation.Value.Fill = (Color)newValue; } }); + + public static readonly BindableProperty TypeProperty = BindableProperty.Create(nameof(Type), typeof(CheckType), typeof(CheckBox), defaultValue: CheckType.Regular, + propertyChanged: (bindable, oldValue, newValue)=> (bindable as CheckBox).UpdateType()); #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member #endregion diff --git a/src/Xamarin.Forms.InputKit/Shared/Controls/CheckBox.cs b/src/Xamarin.Forms.InputKit/Shared/Controls/CheckBox.cs index 8388b94..16316fe 100644 --- a/src/Xamarin.Forms.InputKit/Shared/Controls/CheckBox.cs +++ b/src/Xamarin.Forms.InputKit/Shared/Controls/CheckBox.cs @@ -13,10 +13,6 @@ namespace Plugin.InputKit.Shared.Controls { - /// - /// A checkbox for boolean inputs. It Includes a text inside - /// - /// /// A checkbox for boolean inputs. It Includes a text inside /// @@ -68,7 +64,6 @@ public partial class CheckBox : StatefulStackLayout, IValidatable }; protected Lazy iconValidation; - private CheckType _type = CheckType.Regular; private bool _isEnabled; #endregion @@ -203,7 +198,7 @@ public Color Color /// /// Which icon will be shown when checkbox is checked /// - public CheckType Type { get => _type; set { _type = value; UpdateType(); } } + public CheckType Type { get => (CheckType)GetValue(TypeProperty); set => SetValue(TypeProperty, value); } /// /// Size of Checkbox @@ -329,7 +324,9 @@ public void DisplayValidation() { checkBox.iconValidation.Value.Fill = ((Color)newValue).ToBrush(); } - }); + }); + public static readonly BindableProperty TypeProperty = BindableProperty.Create(nameof(Type), typeof(CheckType), typeof(CheckBox), defaultValue: CheckType.Regular, + propertyChanged: (bindable, oldValue, newValue) => (bindable as CheckBox).UpdateType()); #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member #endregion