1

Trying to fix an issue I'm seeing on both Android & iOS in dark mode where the border of my radio button is not showing up. Once the button is pressed, the filled circle shows up for the checked selection, but I need both unchecked radio button circles to be there so the user knows the buttons are there. Anyone know how to get radio button formatting to work correctly in dark mode?

Here's the xaml for the buttons:

<RadioButton x:Name="MyRadio0No" Grid.Row="0" Grid.Column="1" Content="No" BackgroundColor="White" BorderColor="{StaticResource AppMainColor}" FontSize="Body" TextColor="{StaticResource AppMainColor}" IsChecked="false"  CheckedChanged="OnRadioButton0CheckedChanged" />
<RadioButton x:Name="MyRadio0Yes" Grid.Row="0" Grid.Column="2" Content="Yes" BackgroundColor="White" BorderColor="{StaticResource AppMainColor}" FontSize="Body" TextColor="{StaticResource AppMainColor}" IsChecked="false" HorizontalOptions="EndAndExpand" CheckedChanged="OnRadioButton0CheckedChanged"/>

Result in light mode:

enter image description here

Result in dark mode:

enter image description here

I've also tried setting the border color in Styles.xaml as well as specifying it for dark mode, but this didn't change anything:

<Style TargetType="RadioButton">
     <Setter Property="BorderColor" Value="{AppThemeBinding Light={StaticResource AppMainColor}, Dark={StaticResource AppMainColor}}" />
     ...
</Style>
6
  • What happens when you click on it does it work? Commented Jul 7, 2024 at 1:53
  • @FreakyAli it works, they are just white brush drawn on white background :) Commented Jul 8, 2024 at 3:31
  • @jess github.com/dotnet/maui/issues/15795 just notice the statement "low priority"... Commented Jul 8, 2024 at 3:39
  • @jess so did you find a solution yet? Commented Jul 8, 2024 at 15:54
  • @FreakyAli Nope, still trying to figure it out Commented Jul 19, 2024 at 19:40

4 Answers 4

1

The BorderColor property for RadioButton in .NET MAUI does not work as expected due to platform inconsistencies. This is a known issue, and many developers have encountered it.

Workarounds to Fix the RadioButton
You want to customized control like Frame, Border or you can achive the default color in using Handlers, Renderers from native

Sign up to request clarification or add additional context in comments.

Comments

0

I did a test on my side, and I could reproduce this problem on my side. We should avoid using colors that are close to or the same as the background, otherwise we will run into problems just as you mentioned.

So, if I removed code BackgroundColor="White", and this problem will not recur in dark mode.

My test code is as follows:

<RadioButton x:Name="MyRadio0No" Content="No"  FontSize="Body" TextColor="Black" IsChecked="false"/>

5 Comments

Unfortunately, I need to specify the BackgroundColor otherwise it turns grey/black on some devices in dark mode and looks really bad. I want the background to be white and the radio button to be a dark color, so it should show up very clearly
You can specify the BackgroundColor, but BackgroundColor and the BorderColor color should not be similar, otherwise the problem you said will still appear.
Well this is another Maui bug then because my BackgroundColor and BorderColor are very different
Could you please post the link of this Maui bug as you mentioned above?
I don't have a link for you, see above for the screenshots/description of issue. I think it's a bug because implementing these properties isn't showing up correctly/at all in the UI
0
if (Current != null)
{
    Current.UserAppTheme = AppTheme.Light;
}

Note: In the Platforms/iOS/Info.plist file, add UIViewControllerBasedStatusBarAppearance key and value. key: UIViewControllerBasedStatusBarAppearance value: false

Comments

0

Check with Native Android Theme in Manifest - Use DayNight

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.