Xamarin.Forms.InputKit icon indicating copy to clipboard operation
Xamarin.Forms.InputKit copied to clipboard

Not able to customize the SelectionView

Open ronakshethia opened this issue 5 years ago • 8 comments

i am not able to change the color of radio circle and also not able to resize the font of the radio button could u please provide that functionality

ronakshethia avatar Mar 14 '19 10:03 ronakshethia

@ronakshethia Of course. That is right.

SelectionView is not a real control. just generates RadioButtons, CheckBoxes or buttons at runtime. It uses Control's default settings.

If your SelectionType is CheckBox you can try change GlobalSetting of CheckBox.

-- For example.

if you have that:

<input:SelectionView ItemsSource="{Binding SampleList}" SelectionType="CheckBox" />

go to your App.cs

    public App()
        {
            InitializeComponent();
	    
            //also this will changes default values of all checkboxes in your app
            Plugin.InputKit.Shared.Controls.CheckBox.GlobalSetting.BorderColor = Color.Blue;

            MainPage = new NavigationPage(new Sample.InputKit.MainPage());
        }

If you havethat:

<input:SelectionView ItemsSource="{Binding SampleList}" SelectionType="RadioButton" />

go to your App.cs

    public App()
        {
            InitializeComponent();
            //also this will changes default values of all radiobuttons in your app
            Plugin.InputKit.Shared.Controls.RadioButton.GlobalSetting.BorderColor = Color.Blue;

            MainPage = new NavigationPage(new Sample.InputKit.MainPage());
        }

enisn avatar Mar 14 '19 10:03 enisn

I'm labeling this issue as Enchantment and customizing feature will be added to selectionview

enisn avatar Mar 14 '19 10:03 enisn

Thanks it worked for me :)

ronakshethia avatar Mar 14 '19 11:03 ronakshethia

@enisn Your solution form above is working, but when I select any RadioButton from SelectionView - style of selected button is going back to default "pink-gray". I have tested it in SelectionView and RadioButtonGroupView with radio buttons, with the same results in both.

Klewerro avatar Aug 26 '19 09:08 Klewerro

I couldn't get the GlobalSetting to work for me, I need to set it in a Theme Detection class to set colors for Dark mode vs light mode.

HelenMamalaki avatar Jun 16 '20 13:06 HelenMamalaki

I'm in the same boat as @HelenMamalaki on this. Any work around?

DevonHansen avatar Aug 27 '20 10:08 DevonHansen

Me too

aismaniotto avatar Nov 16 '20 02:11 aismaniotto

Also, overriding SelectionView is a workaround for now:

using Plugin.InputKit.Shared.Abstraction;
using Plugin.InputKit.Shared.Controls;

namespace App3
{
    public class MySelectionView : SelectionView
    {
        public override ISelection GetInstance(object obj)
        {
            var instance = base.GetInstance(obj);

            if (instance is Plugin.InputKit.Shared.Controls.CheckBox checkBox)
            {
                checkBox.BoxSizeRequest = 18;
                checkBox.TextFontSize = 22;
                checkBox.SetDynamicResource(Plugin.InputKit.Shared.Controls.CheckBox.IconColorProperty, "SecondaryColor");
            }

            return instance;
        }
    }
}

enisn avatar Apr 07 '21 21:04 enisn