dotnet / dotnet/maui

SetDynamicResource does not update the Background property of the Label

Open
#37,540 1 comment 1 reaction 0 assignees View on GitHub
area-controls-label partner/syncfusion platform/android platform/ios platform/macos 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

A Label control is initialized with a transparent background in XAML. During the Loaded event, a DynamicResource is programmatically applied to the label's BackgroundProperty using SetDynamicResource.

Although the resource key resolves to a valid color resource (Red), the label background remains Transparent at runtime instead of updating to Red.

### Steps to Reproduce

1. Define a color resource in ContentPage.Resources.
2. Create a Label with Background="Transparent".
3. In the Loaded event, call SetDynamicResource on the label's background property using the resource key.
4. Run the application.

I have attached the reproducible sample. Kindly check the issue in the sample.

[CustomSample.zip](https://github.com/user-attachments/files/31137955/CustomSample.zip)

**Expected behavior:**
After the Loaded event executes, the backgroundColor resource should be resolved and applied to the label's background. The label background should change from Transparent to Red.

**Actual behavior:**
The SetDynamicResource call completes successfully, but the label background remains Transparent.

### Link to public reproduction project repository

_No response_

### Version with bug

10.0.90

### 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, macOS, iOS

### 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 by running the attached CustomSample.zip reproduction and inspect the Label's Loaded event, where SetDynamicResource is called for BackgroundProperty. Compare the runtime background with the expected Red resource value; done means the Label changes from Transparent to Red after Loaded on the affected platforms.

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
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.