dotnet / dotnet/maui

RadioButton ellipse colors are not applied

Open
#35,645 3 comments 1 reaction 0 assignees View on GitHub
area-controls-radiobutton has-workaround partner/syncfusion platform/android platform/windows s/triaged s/verified t/bug
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 15h
Merged PRs (30d)
290

Description

### Description

Supposedly you should be able to configure the colors of the RadioButton ellipses using Brushes with [these keys](https://github.com/dotnet/maui/blob/b0ea772fff1466e9d6b8d8660d4ffce03c202b96/src/Controls/src/Core/RadioButton/RadioButton.cs#L54-L64) according to [this PR](https://github.com/dotnet/maui/pull/14117).

However, this doesn't work as expected.

First issue I think I could identify is that [`Application.Current.TryGetResource`](https://github.com/dotnet/maui/blob/main/src/Controls/src/Core/ResourcesExtensions.cs#L58) as used in [`RadioButton.BuildDefaultTemplate`](https://github.com/dotnet/maui/blob/b0ea772fff1466e9d6b8d8660d4ffce03c202b96/src/Controls/src/Core/RadioButton/RadioButton.cs#L502) via [`BindableObjectExtensions.TrySetDynamicThemeColor`](https://github.com/dotnet/maui/blob/main/src/Controls/src/Core/BindableObjectExtensions.cs#L168) and [`BindableObjectExtensions.TrySetAppTheme`](https://github.com/dotnet/maui/blob/main/src/Controls/src/Core/BindableObjectExtensions.cs#L195) doesn't seem to find those brushes in merged dictionaries - only if they are in the top level `Application.Resources`.
So I'd have to customize these colors in my `App.xaml` instead of my `Colors.xaml`, where I would expect to do it.

But even if I define brushes with the magic keys in my `App.xaml` like the following, they're not applied.

```xaml
#954C2E
#954C2E
#954C2E
#954C2E
#954C2E
#954C2E
```

### Steps to Reproduce

_No response_

### Link to public reproduction project repository

_No response_

### Version with bug

10.0.70

### Is this a regression from previous behavior?

Not sure, did not test other versions

### Last version that worked well

Unknown/Other

### Affected platforms

Android, Windows

### Affected platform versions

_No response_

### Did you find any workaround?

_No response_

### Relevant log output

```shell

```

Contributor guide

Open the contributing guide

Research direction

Start with RadioButton.BuildDefaultTemplate in src/Controls/src/Core/RadioButton/RadioButton.cs, then trace TrySetDynamicThemeColor and TrySetAppTheme in BindableObjectExtensions.cs and TryGetResource in ResourcesExtensions.cs. Reproduce the issue with the six documented brush keys in App.xaml and a merged Colors.xaml; done means the configured light and dark brushes are applied to the RadioButton ellipses from both resource locations.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.