Skip to content

Commit 8bbb4e0

Browse files
committed
Fix checkbox icon color
1 parent 4b837c1 commit 8bbb4e0

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

sandbox/SandboxMAUI/Pages/CheckBoxPage.xaml.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,10 @@ private void Button_Clicked(object sender, EventArgs e)
2323
chk.Color = color;
2424
}
2525
}
26+
27+
if(sender is Button button)
28+
{
29+
button.BackgroundColor = color;
30+
}
2631
}
2732
}

src/InputKit/Shared/Controls/CheckBox.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public LabelPosition LabelPosition
220220
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
221221
public static readonly BindableProperty ColorProperty = BindableProperty.Create(nameof(Color), typeof(Color), typeof(CheckBox), GlobalSetting.Color, propertyChanged: (bo, ov, nv) => (bo as CheckBox).UpdateColors());
222222
public static readonly BindableProperty TextColorProperty = BindableProperty.Create(nameof(TextColor), typeof(Color), typeof(CheckBox), GlobalSetting.TextColor, propertyChanged: (bo, ov, nv) => (bo as CheckBox).TextColor = (Color)nv);
223-
public static readonly BindableProperty IconColorProperty = BindableProperty.Create(nameof(IconColor), typeof(Color), typeof(CheckBox), GlobalSetting.Color, propertyChanged: (bo, ov, nv) => (bo as CheckBox).UpdateColors());
223+
public static readonly BindableProperty IconColorProperty = BindableProperty.Create(nameof(IconColor), typeof(Color), typeof(CheckBox), Colors.Transparent, propertyChanged: (bo, ov, nv) => (bo as CheckBox).UpdateColors());
224224
public static readonly BindableProperty IsCheckedProperty = BindableProperty.Create(nameof(IsChecked), typeof(bool), typeof(CheckBox), false, BindingMode.TwoWay, propertyChanged: (bo, ov, nv) => (bo as CheckBox).ApplyIsCheckedAction(bo as CheckBox, (bool)nv));
225225
public static readonly BindableProperty IsDisabledProperty = BindableProperty.Create(nameof(IsDisabled), typeof(bool), typeof(CheckBox), false, propertyChanged: (bo, ov, nv) => (bo as CheckBox).IsDisabled = (bool)nv);
226226
public static readonly BindableProperty KeyProperty = BindableProperty.Create(nameof(Key), typeof(int), typeof(CheckBox), 0, propertyChanged: (bo, ov, nv) => (bo as CheckBox).Key = (int)nv);
@@ -282,17 +282,14 @@ void UpdateColors()
282282
{
283283
frmBackground.BorderColor = Color;
284284
frmBackground.BackgroundColor = IsChecked ? Color : Colors.Transparent;
285+
imgSelected.FillColor = Color.ToSurfaceColor();
285286
}
286287
else
287288
{
288289
frmBackground.BorderColor = IsChecked ? Color : BorderColor;
289290
frmBackground.BackgroundColor = BoxBackgroundColor;
291+
imgSelected.FillColor = IconColor == Colors.Transparent ? Color : IconColor;
290292
}
291-
292-
imgSelected.FillColor =
293-
IconColor == frmBackground.BackgroundColor ?
294-
IconColor.ToSurfaceColor() :
295-
IconColor;
296293
}
297294

298295
void UpdateBorderColor()

0 commit comments

Comments
 (0)