Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

[Bug] Unable to style RadioButton icon color #10320

Open
davidortinau opened this issue Apr 13, 2020 · 14 comments
Open

[Bug] Unable to style RadioButton icon color #10320

davidortinau opened this issue Apr 13, 2020 · 14 comments
Labels
a/radiobutton 🔘 a/style e/3 🕒 3 in-progress This issue has an associated pull request that may resolve it! t/bug 🐛

Comments

@davidortinau
Copy link
Contributor

Description

The control offers background color, text color, and border color. Those are all button properties. I need to be able to set the color for the radio button itself.

<StackLayout Spacing="12">
                <Label Text="RadioButton" Style="{ DynamicResource TextSubHead }" />
                <RadioButton GroupName="radio" Text="One" IsChecked="True"/>
                <RadioButton GroupName="radio" Text="Two"/>
                <RadioButton GroupName="radio" Text="Three"/>
                <RadioButton GroupName="radio" Text="Four"/>
            </StackLayout>

Styles:

<!-- RadioButton -->
    <Style TargetType="RadioButton">
        <Setter Property="TextColor" Value="{DynamicResource TextPrimaryColor}"/>
    </Style>

image

Expected Behavior

I can set the color of the radio button graphic.

Actual Behavior

No property is available. I also tried overriding the ImageSource to no avail.

<RadioButton GroupName="radio" Text="One" IsChecked="True">
                    <RadioButton.ImageSource>
                        <FontImageSource
                            FontFamily="FontAwesome"
                            Glyph="{x:Static local:IconFont.GraduationCap}"
                            Color="Black"
                            Size="16"/>
                    </RadioButton.ImageSource>
                </RadioButton>

My preference is to have a simple color property first, then the option to replace the image altogether.

Basic Information

  • Version with issue: 4.6-pre4
  • Last known good version:
    • Android: 10
@davidortinau davidortinau added t/bug 🐛 s/unverified New report that has yet to be verified labels Apr 13, 2020
@samhouts samhouts added blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. e/3 🕒 3 and removed s/unverified New report that has yet to be verified labels Apr 17, 2020
@jfversluis jfversluis self-assigned this Apr 21, 2020
@jfversluis
Copy link
Member

For the graphic there was ButtonSource which was only implemented for Android, so I removed that for now in #9967 so we can still get this in.

Do we also need a color for checked state and unchecked state? CheckBox has that. Or people can do that with the VSM?

@davidortinau
Copy link
Contributor Author

I think our default position should be VSM with appropriate states implemented.

@samhouts samhouts added the in-progress This issue has an associated pull request that may resolve it! label Apr 22, 2020
@samhouts samhouts assigned jfversluis and unassigned jfversluis May 4, 2020
@JesseLiberty
Copy link

A bit confused: is this fixed with VSM? I need to be able to turn the circle green while leaving the text black. Is that this issue?

@jfversluis jfversluis removed their assignment Jun 19, 2020
@jfversluis
Copy link
Member

@JesseLiberty this is not fixed with the VSM. David's remark was about not forgetting the VSM is there and we should take that into account implementing this functionality.

Unassigning myself for now, not sure when and if I will be able to put in the dedicated effort to do this. Feel free to take the PR that is there and iterate on that.

@samhouts samhouts removed the blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. label Jul 13, 2020
@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
@viktorszekeress
Copy link

This issue has been here since April. What happened? I'm on XF 5.0 pre-3 and it's still not there. I don't even understand what author was thinking, when RadioButton was released. Something like, I will provide devs with TextColor, BackgroundColor, BorderColor, but not RadioColor, uhmmm that's okay... no one will want to change that color.

C'mon guys, you should really try to spend couple hours with Flutter. It's impossible you would find such thinking there.

@jfversluis
Copy link
Member

@viktorszekeress did you actually try the (new) radiobutton? Or just basing it off this issue? Because looks like me we can style the whole thing, including color nowadays.

@jfversluis
Copy link
Member

@hartez can this be closed to that regard?

@viktorszekeress
Copy link

@jfversluis I tried RadioButton that is available in XF 5.0 pre-3. It has Content property, which (according to a comment in the code) should accept a string or a View. While string value works OK, there must a bug, because if I put a Label there, it displays "Xamarin.Forms.Label".

Then, there is ControlTemplate property, which I don't want to use, because it will remove all the 'built-in' design and functionality.

All I want is to keep the design, just change the color of the radio indicator. Can you provide me an example of how to do that?

@Cfun1
Copy link

Cfun1 commented Dec 2, 2020

@viktorszekeress did you actually try the (new) radiobutton? Or just basing it off this issue? Because looks like me we can style the whole thing, including color nowadays.

@jfversluis I think it is still not possible to do it at Xamarin.Forms level, also it create an issue with the circle not visible under Android >=10 with light theme enabled and a default style. A workaround would be adding <item name="android:colorControlNormal ">#FF4081</item> to Styles.xml.

@jfversluis
Copy link
Member

Reading it back it wasn't meant to be snarky, sorry about that :) I just didn't know either. It looks like there are a lot of (new) possibilities now, so I was just wondering. Thanks for the suggestion @Cfun1 !

@Cfun1
Copy link

Cfun1 commented Dec 2, 2020

@jfversluis I know you were just wondering, I didn't think/feel you were writing in a snarky way when I have read your message :)

@AdamDiament
Copy link

Bump! I also want to be able to style my radio button circle independently of other controls. The workaround adding name="android:colorControlNormal ">#FF4081</item> to styles.xml does indeed work for android, but it also adds this tint color to all editable controls, such as adding an underline to each input element, which I don't want. It's robbing Peter to pay Paul!

@DamienDoumer
Copy link

I still have this issue when my app is in dark mode, the radio button's border is white no matter which color I set in the styles.

@TerraNqobile
Copy link

I still have this problem when my app is in dark mode, the radio button's are white no matter which color I set in the styles.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/radiobutton 🔘 a/style e/3 🕒 3 in-progress This issue has an associated pull request that may resolve it! t/bug 🐛
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants