@@ -385,22 +385,30 @@ private void SetInstanceColor(IView view, Color color)
385
385
case SelectionType . Button :
386
386
case SelectionType . MultipleButton :
387
387
{
388
- if ( view is Button )
388
+ if ( view is SelectableButton sb )
389
389
{
390
- ( view as Button ) . BackgroundColor = color ;
390
+ sb . SelectedColor = color ;
391
+ }
392
+ else if ( view is Button button )
393
+ {
394
+ button . BackgroundColor = color ;
391
395
}
392
396
}
393
397
break ;
394
398
case SelectionType . RadioButton :
395
399
{
396
- if ( view is SelectableRadioButton )
397
- ( view as SelectableRadioButton ) . Color = color ;
400
+ if ( view is SelectableRadioButton srb )
401
+ {
402
+ srb . Color = color ;
403
+ }
398
404
}
399
405
break ;
400
406
case SelectionType . CheckBox :
401
407
{
402
- if ( view is SelectableCheckBox )
403
- ( view as SelectableCheckBox ) . Color = color ;
408
+ if ( view is SelectableCheckBox scb )
409
+ {
410
+ scb . Color = color ;
411
+ }
404
412
}
405
413
break ;
406
414
}
@@ -459,7 +467,6 @@ public class SelectableButton : Button, ISelection
459
467
private bool _isSelected = false ;
460
468
private object _value ;
461
469
private Color _selectionColor = InputKitOptions . GetAccentColor ( ) ;
462
- private Color _unselectedColor ;
463
470
464
471
/// <summary>
465
472
/// Default constructor
@@ -482,7 +489,6 @@ public SelectableButton(object value) : this()
482
489
FontSize = GlobalSetting . FontSize ;
483
490
CornerRadius = ( int ) GlobalSetting . CornerRadius ;
484
491
BorderColor = GlobalSetting . BorderColor ;
485
- UnselectedColor = GlobalSetting . BackgroundColor ;
486
492
BorderWidth = 2 ;
487
493
Clicked += ( s , args ) => UpdateSelection ( ) ;
488
494
}
@@ -497,7 +503,10 @@ public SelectableButton(object value, SelectionView parent) : this(value)
497
503
SelectedColor = parent . Color ;
498
504
}
499
505
500
- public Color UnselectedColor { get => _unselectedColor ; set { _unselectedColor = value ; UpdateColors ( ) ; } }
506
+ public static readonly BindableProperty UnSelectedColorProperty = BindableProperty . Create ( nameof ( UnselectedColor ) , typeof ( Color ) , typeof ( SelectableButton ) ,
507
+ defaultValue : GlobalSetting . BackgroundColor , propertyChanged : ( bo , ov , nv ) => ( bo as SelectableButton ) . UpdateColors ( ) ) ;
508
+
509
+ public Color UnselectedColor { get => ( Color ) GetValue ( UnSelectedColorProperty ) ; set => SetValue ( UnSelectedColorProperty , value ) ; }
501
510
502
511
public Color SelectedColor
503
512
{
0 commit comments