Skip to content

Let a Style set Shell.FlyoutBackgroundColor - #39839

Merged
kubaflo merged 2 commits into
dotnet:mainfrom
MykhailoDav:fix-9736-shell-flyout-background-color-from-style
Nov 11, 2026
Merged

kubaflo merged 2 commits into
dotnet:mainfrom
MykhailoDav:fix-9736-shell-flyout-background-color-from-style

Conversation

@MykhailoDav

Copy link
Copy Markdown
Contributor

Description of Change

Shell.FlyoutBackgroundColor set from a Style, implicit or explicit, was ignored. Only a value set directly on the Shell worked, and FlyoutBackground worked from a Style.

Root cause

The Shell constructor binds FlyoutBackgroundColor to an AppThemeBinding for the default white/black colors. It uses the public SetBinding, which applies the binding with SetterSpecificity.FromBinding, and a binding outranks every Style setter; only a value set directly on the element is higher. So the default always won over a Style.

Fix

The default binding is applied with the lowest specificity, new SetterSpecificity(), through the same internal overload Setter uses for bindings in styles. A Style setter or a value set directly on the Shell now wins over it, and when nothing else sets the property the theme colors still apply, including when the theme changes. The Material 3 path on Android, which doesn't create this binding, is unchanged.

Tests

In AppThemeTests:

  • StyleSetsShellFlyoutBackgroundColor: an implicit Shell style sets the color, and it stays after a theme change.
  • ShellFlyoutBackgroundColorFollowsTheThemeWithoutAStyle: without a style the default is still white in light and black in dark.
Without fix With fix
main (4c74701) First test fails: White instead of Red Both pass; Controls.Core.UnitTests 6735 passed

Issues Fixed

Fixes #9736

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 39839

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 39839"

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Nov 3, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @@MykhailoDav! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@azure-pipelines

This comment has been minimized.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @MykhailoDav! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@kubaflo

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 3, 2026
@azure-pipelines

This comment has been minimized.

@MauiBot

This comment has been minimized.

@MauiBot MauiBot added s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) and removed s/agent-review-in-progress AI review is currently running for this PR labels Nov 3, 2026
@kubaflo

kubaflo commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

/rebase

The Shell constructor binds FlyoutBackgroundColor to an AppThemeBinding for the
default white/black colors. A binding has a higher specificity than any Style
setter, so a FlyoutBackgroundColor set from a Style, implicit or explicit, was
ignored and only a value set directly on the Shell worked.

The default binding now uses the lowest specificity, like the other Shell
defaults, so a Style wins over it while the theme colors still apply when
nothing else sets the property.

Fixes dotnet#9736
@github-actions
github-actions Bot force-pushed the fix-9736-shell-flyout-background-color-from-style branch from d51dedd to 520e114 Compare November 3, 2026 13:44
@kubaflo

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 3, 2026
@azure-pipelines

This comment has been minimized.

@MauiBot

This comment has been minimized.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 3, 2026
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 3, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 0 findings

Reviewed commit 520e114.

@MauiBot

MauiBot commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@MykhailoDav — existing-test verification for commit 520e1141.

Result PASSED Platform Android Commit 520e1141


🧪 Gate analysis — click to expand

✅ Passed. The selected verification satisfied the gate's passing conditions. Unmatched, skipped, or inconclusive groups are not passing evidence.

🧪 Unit tests
Test group Without fix With fix
AppThemeTests ✅ Failed as expected (73s) ✅ Passed (46s)
Execution log excerpts

Without fix AppThemeTests

     at Microsoft.Maui.Controls.Core.UnitTests.AppThemeTests.StyleSetsShellFlyoutBackgroundColor() in /_/src/Controls/tests/Core.UnitTests/AppThemeTests.cs:line 211
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

With fix AppThemeTests

0.56]   Discovering: Microsoft.Maui.Controls.Core.UnitTests
[xUnit.net 00:00:04.71]   Discovered:  Microsoft.Maui.Controls.Core.UnitTests
[xUnit.net 00:00:04.72]   Starting:    Microsoft.Maui.Controls.Core.UnitTests
  Passed SettingSameUserThemeDoesNotFireEvent [18 ms]
  Passed ThemeChangeUsingSetBinding [108 ms]
  Passed UnsettingUserThemeReverts [1 ms]
  Passed ParentSetResolvesAppThemeDynamicResourceWithoutListener [1 ms]
  Passed ThemeChangeUsingUserAppTheme [< 1 ms]
  Passed NullApplicationCurrentFallsBackToEssentials [< 1 ms]
  Passed ThemeBindingRemovedOnOneTimeBindablePropertyWhenPropertySet [16 ms]
  Passed InitialThemeIsCorrect [< 1 ms]
  Passed SettingDifferentUserThemeDoesNotFireEvent [< 1 ms]
[xUnit.net 00:00:05.17]   Finished:    Microsoft.Maui.Controls.Core.UnitTests
  Passed BindingConversion [2 ms]
  Passed ThemeChangeUsingSetAppTheme [2 ms]
  Passed ShellFlyoutBackgroundColorFollowsTheThemeWithoutAStyle [3 ms]
  Passed StyleSetsShellFlyoutBackgroundColor [23 ms]
  Passed ThemeChangeUsingSetAppThemeColor [< 1 ms]
  Passed CorrectDefaultRadioButtonThemeColorsInLightAndDarkModes [185 ms]
Test Run Successful.
Total tests: 15
     Passed: 15
 Total time: 6.2625 Seconds

PR head: 520e1141.

Without-fix baseline: b4f1d314.

@kubaflo
kubaflo requested a balanced review from Copilot November 3, 2026 15:36
@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block approval of the Shell flyout background styling change.

No open issues 🎉

What changed in this PR

Fixes #9736 by allowing styles to override .NET MAUI Shell’s default flyout background color while preserving theme-aware defaults.

Changes:

  • Applies the default AppThemeBinding at the lowest setter specificity so style values take precedence.
  • Adds regression tests for an implicit style surviving a theme change and for unstyled Shell colors following the theme.
  • Leaves the Android Material 3 path unchanged.
File Description
src/​Controls/​tests/​Core.UnitTests/​AppThemeTests.cs Adds coverage for style precedence and theme-aware default colors.
src/​Controls/​src/​Core/​Shell/​Shell.cs Lowers the default flyout background binding’s specificity so styles can override it.

Review effort: Balanced

@kubaflo
kubaflo merged commit 9291bfb into dotnet:main Nov 11, 2026
164 of 172 checks passed
Ahamed-Ali pushed a commit to Ahamed-Ali/maui that referenced this pull request Nov 12, 2026
### Description of Change

`Shell.FlyoutBackgroundColor` set from a `Style`, implicit or explicit,
was ignored. Only a value set directly on the `Shell` worked, and
`FlyoutBackground` worked from a `Style`.

**Root cause**

The `Shell` constructor binds `FlyoutBackgroundColor` to an
`AppThemeBinding` for the default white/black colors. It uses the public
`SetBinding`, which applies the binding with
`SetterSpecificity.FromBinding`, and a binding outranks every `Style`
setter; only a value set directly on the element is higher. So the
default always won over a `Style`.

**Fix**

The default binding is applied with the lowest specificity, `new
SetterSpecificity()`, through the same internal overload `Setter` uses
for bindings in styles. A `Style` setter or a value set directly on the
`Shell` now wins over it, and when nothing else sets the property the
theme colors still apply, including when the theme changes. The Material
3 path on Android, which doesn't create this binding, is unchanged.

**Tests**

In `AppThemeTests`:
- `StyleSetsShellFlyoutBackgroundColor`: an implicit `Shell` style sets
the color, and it stays after a theme change.
- `ShellFlyoutBackgroundColorFollowsTheThemeWithoutAStyle`: without a
style the default is still white in light and black in dark.

| | Without fix | With fix |
|---|---|---|
| `main` (4c74701) | First test fails: White instead of Red | Both
pass; Controls.Core.UnitTests 6735 passed |

### Issues Fixed

Fixes dotnet#9736

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Ahamed-Ali added a commit to Ahamed-Ali/maui that referenced this pull request Nov 12, 2026
This reverts commit c14cab3 to keep the Windows CV1 PR scoped to its pipeline change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
SyedAbdulAzeemSF4852 pushed a commit to SyedAbdulAzeemSF4852/maui that referenced this pull request Nov 12, 2026
### Description of Change

`Shell.FlyoutBackgroundColor` set from a `Style`, implicit or explicit,
was ignored. Only a value set directly on the `Shell` worked, and
`FlyoutBackground` worked from a `Style`.

**Root cause**

The `Shell` constructor binds `FlyoutBackgroundColor` to an
`AppThemeBinding` for the default white/black colors. It uses the public
`SetBinding`, which applies the binding with
`SetterSpecificity.FromBinding`, and a binding outranks every `Style`
setter; only a value set directly on the element is higher. So the
default always won over a `Style`.

**Fix**

The default binding is applied with the lowest specificity, `new
SetterSpecificity()`, through the same internal overload `Setter` uses
for bindings in styles. A `Style` setter or a value set directly on the
`Shell` now wins over it, and when nothing else sets the property the
theme colors still apply, including when the theme changes. The Material
3 path on Android, which doesn't create this binding, is unchanged.

**Tests**

In `AppThemeTests`:
- `StyleSetsShellFlyoutBackgroundColor`: an implicit `Shell` style sets
the color, and it stays after a theme change.
- `ShellFlyoutBackgroundColorFollowsTheThemeWithoutAStyle`: without a
style the default is still white in light and black in dark.

| | Without fix | With fix |
|---|---|---|
| `main` (4c74701) | First test fails: White instead of Red | Both
pass; Controls.Core.UnitTests 6735 passed |

### Issues Fixed

Fixes dotnet#9736

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
praveenkumarkarunanithi pushed a commit to devanathan-vaithiyanathan/maui that referenced this pull request Nov 12, 2026
### Description of Change

`Shell.FlyoutBackgroundColor` set from a `Style`, implicit or explicit,
was ignored. Only a value set directly on the `Shell` worked, and
`FlyoutBackground` worked from a `Style`.

**Root cause**

The `Shell` constructor binds `FlyoutBackgroundColor` to an
`AppThemeBinding` for the default white/black colors. It uses the public
`SetBinding`, which applies the binding with
`SetterSpecificity.FromBinding`, and a binding outranks every `Style`
setter; only a value set directly on the element is higher. So the
default always won over a `Style`.

**Fix**

The default binding is applied with the lowest specificity, `new
SetterSpecificity()`, through the same internal overload `Setter` uses
for bindings in styles. A `Style` setter or a value set directly on the
`Shell` now wins over it, and when nothing else sets the property the
theme colors still apply, including when the theme changes. The Material
3 path on Android, which doesn't create this binding, is unchanged.

**Tests**

In `AppThemeTests`:
- `StyleSetsShellFlyoutBackgroundColor`: an implicit `Shell` style sets
the color, and it stays after a theme change.
- `ShellFlyoutBackgroundColorFollowsTheThemeWithoutAStyle`: without a
style the default is still white in light and black in dark.

| | Without fix | With fix |
|---|---|---|
| `main` (4c74701) | First test fails: White instead of Red | Both
pass; Controls.Core.UnitTests 6735 passed |

### Issues Fixed

Fixes dotnet#9736

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 13, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Revert #39839 on `main` as requested. This restores the previous
behavior: a `Style` cannot override the default
`Shell.FlyoutBackgroundColor` binding until the candidate fix is
forwarded to `main`.

The identical implementation and regression tests are already on
`candidate/11.0.1xx-sr2`, where they were included in #40170 (commit
`706b461e9296fd30f7ff3c057dacf2025d60a698`). A separate candidate PR for
the same patch would be empty, so this PR changes only `main`.

### Validation

- Verified the commit is the exact inverse of
`9291bfb20edde2cc822b8e2a110f63d2b3425e09`; both changed files match
their pre-fix blobs.
- `dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug
-p:IncludeIosTargetFrameworks=false
-p:IncludeAndroidTargetFrameworks=false
-p:IncludeMacCatalystTargetFrameworks=false
-p:IncludeWindowsTargetFrameworks=false
-p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false
--verbosity quiet` — passed.
- `dotnet test
src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj
--no-restore -c Debug -p:IncludeIosTargetFrameworks=false
-p:IncludeAndroidTargetFrameworks=false
-p:IncludeMacCatalystTargetFrameworks=false
-p:IncludeWindowsTargetFrameworks=false
-p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false
--filter 'FullyQualifiedName~AppThemeTests' --verbosity quiet` — passed:
15 tests before the revert and 13 after removal of the two reverted
tests.
- `dotnet test
src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj
--no-build --no-restore -c Debug -p:IncludeIosTargetFrameworks=false
-p:IncludeAndroidTargetFrameworks=false
-p:IncludeMacCatalystTargetFrameworks=false
-p:IncludeWindowsTargetFrameworks=false
-p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false
--filter 'FullyQualifiedName~ShellTests|FullyQualifiedName~StyleTests'
--verbosity quiet` — passed: 147 tests.
- With the two original regression tests temporarily retained against
the reverted implementation, `dotnet test
src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj
--no-restore -c Debug -p:IncludeIosTargetFrameworks=false
-p:IncludeAndroidTargetFrameworks=false
-p:IncludeMacCatalystTargetFrameworks=false
-p:IncludeWindowsTargetFrameworks=false
-p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false
--filter
'FullyQualifiedName~StyleSetsShellFlyoutBackgroundColor|FullyQualifiedName~ShellFlyoutBackgroundColorFollowsTheThemeWithoutAStyle'
--logger 'console;verbosity=normal'` — expected failure: the style test
received white instead of red; the default-theme test passed. The
temporarily retained tests were removed again before committing.
- The combined selection `dotnet test
src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj
--no-restore -c Debug -p:IncludeIosTargetFrameworks=false
-p:IncludeAndroidTargetFrameworks=false
-p:IncludeMacCatalystTargetFrameworks=false
-p:IncludeWindowsTargetFrameworks=false
-p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false
--filter
'FullyQualifiedName~AppThemeTests|FullyQualifiedName~ShellTests|FullyQualifiedName~StyleTests'
--verbosity quiet` failed
`CorrectDefaultRadioButtonThemeColorsInLightAndDarkModes` (159 passed, 1
failed). The same failure occurred with the original patch restored on
the unmodified `main` baseline (161 passed, 1 failed); the isolated
selections above pass.
- `dotnet format Microsoft.Maui.sln --no-restore --verify-no-changes
--include src/Controls/src/Core/Shell/Shell.cs
src/Controls/tests/Core.UnitTests/AppThemeTests.cs --exclude
Templates/src --exclude-diagnostics CA1822 --verbosity quiet` — passed.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Related to #9736; this revert intentionally restores the issue on
`main`.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
SuthiYuvaraj pushed a commit to SuthiYuvaraj/maui that referenced this pull request Nov 13, 2026
### Description of Change

`Shell.FlyoutBackgroundColor` set from a `Style`, implicit or explicit,
was ignored. Only a value set directly on the `Shell` worked, and
`FlyoutBackground` worked from a `Style`.

**Root cause**

The `Shell` constructor binds `FlyoutBackgroundColor` to an
`AppThemeBinding` for the default white/black colors. It uses the public
`SetBinding`, which applies the binding with
`SetterSpecificity.FromBinding`, and a binding outranks every `Style`
setter; only a value set directly on the element is higher. So the
default always won over a `Style`.

**Fix**

The default binding is applied with the lowest specificity, `new
SetterSpecificity()`, through the same internal overload `Setter` uses
for bindings in styles. A `Style` setter or a value set directly on the
`Shell` now wins over it, and when nothing else sets the property the
theme colors still apply, including when the theme changes. The Material
3 path on Android, which doesn't create this binding, is unchanged.

**Tests**

In `AppThemeTests`:
- `StyleSetsShellFlyoutBackgroundColor`: an implicit `Shell` style sets
the color, and it stays after a theme change.
- `ShellFlyoutBackgroundColorFollowsTheThemeWithoutAStyle`: without a
style the default is still white in light and black in dark.

| | Without fix | With fix |
|---|---|---|
| `main` (4c74701) | First test fails: White instead of Red | Both
pass; Controls.Core.UnitTests 6735 passed |

### Issues Fixed

Fixes dotnet#9736

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
SuthiYuvaraj pushed a commit to SuthiYuvaraj/maui that referenced this pull request Nov 13, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Revert dotnet#39839 on `main` as requested. This restores the previous
behavior: a `Style` cannot override the default
`Shell.FlyoutBackgroundColor` binding until the candidate fix is
forwarded to `main`.

The identical implementation and regression tests are already on
`candidate/11.0.1xx-sr2`, where they were included in dotnet#40170 (commit
`706b461e9296fd30f7ff3c057dacf2025d60a698`). A separate candidate PR for
the same patch would be empty, so this PR changes only `main`.

### Validation

- Verified the commit is the exact inverse of
`9291bfb20edde2cc822b8e2a110f63d2b3425e09`; both changed files match
their pre-fix blobs.
- `dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug
-p:IncludeIosTargetFrameworks=false
-p:IncludeAndroidTargetFrameworks=false
-p:IncludeMacCatalystTargetFrameworks=false
-p:IncludeWindowsTargetFrameworks=false
-p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false
--verbosity quiet` — passed.
- `dotnet test
src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj
--no-restore -c Debug -p:IncludeIosTargetFrameworks=false
-p:IncludeAndroidTargetFrameworks=false
-p:IncludeMacCatalystTargetFrameworks=false
-p:IncludeWindowsTargetFrameworks=false
-p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false
--filter 'FullyQualifiedName~AppThemeTests' --verbosity quiet` — passed:
15 tests before the revert and 13 after removal of the two reverted
tests.
- `dotnet test
src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj
--no-build --no-restore -c Debug -p:IncludeIosTargetFrameworks=false
-p:IncludeAndroidTargetFrameworks=false
-p:IncludeMacCatalystTargetFrameworks=false
-p:IncludeWindowsTargetFrameworks=false
-p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false
--filter 'FullyQualifiedName~ShellTests|FullyQualifiedName~StyleTests'
--verbosity quiet` — passed: 147 tests.
- With the two original regression tests temporarily retained against
the reverted implementation, `dotnet test
src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj
--no-restore -c Debug -p:IncludeIosTargetFrameworks=false
-p:IncludeAndroidTargetFrameworks=false
-p:IncludeMacCatalystTargetFrameworks=false
-p:IncludeWindowsTargetFrameworks=false
-p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false
--filter
'FullyQualifiedName~StyleSetsShellFlyoutBackgroundColor|FullyQualifiedName~ShellFlyoutBackgroundColorFollowsTheThemeWithoutAStyle'
--logger 'console;verbosity=normal'` — expected failure: the style test
received white instead of red; the default-theme test passed. The
temporarily retained tests were removed again before committing.
- The combined selection `dotnet test
src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj
--no-restore -c Debug -p:IncludeIosTargetFrameworks=false
-p:IncludeAndroidTargetFrameworks=false
-p:IncludeMacCatalystTargetFrameworks=false
-p:IncludeWindowsTargetFrameworks=false
-p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false
--filter
'FullyQualifiedName~AppThemeTests|FullyQualifiedName~ShellTests|FullyQualifiedName~StyleTests'
--verbosity quiet` failed
`CorrectDefaultRadioButtonThemeColorsInLightAndDarkModes` (159 passed, 1
failed). The same failure occurred with the original patch restored on
the unmodified `main` baseline (161 passed, 1 failed); the isolated
selections above pass.
- `dotnet format Microsoft.Maui.sln --no-restore --verify-no-changes
--include src/Controls/src/Core/Shell/Shell.cs
src/Controls/tests/Core.UnitTests/AppThemeTests.cs --exclude
Templates/src --exclude-diagnostics CA1822 --verbosity quiet` — passed.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Related to dotnet#9736; this revert intentionally restores the issue on
`main`.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
### Description of Change

`Shell.FlyoutBackgroundColor` set from a `Style`, implicit or explicit,
was ignored. Only a value set directly on the `Shell` worked, and
`FlyoutBackground` worked from a `Style`.

**Root cause**

The `Shell` constructor binds `FlyoutBackgroundColor` to an
`AppThemeBinding` for the default white/black colors. It uses the public
`SetBinding`, which applies the binding with
`SetterSpecificity.FromBinding`, and a binding outranks every `Style`
setter; only a value set directly on the element is higher. So the
default always won over a `Style`.

**Fix**

The default binding is applied with the lowest specificity, `new
SetterSpecificity()`, through the same internal overload `Setter` uses
for bindings in styles. A `Style` setter or a value set directly on the
`Shell` now wins over it, and when nothing else sets the property the
theme colors still apply, including when the theme changes. The Material
3 path on Android, which doesn't create this binding, is unchanged.

**Tests**

In `AppThemeTests`:
- `StyleSetsShellFlyoutBackgroundColor`: an implicit `Shell` style sets
the color, and it stays after a theme change.
- `ShellFlyoutBackgroundColorFollowsTheThemeWithoutAStyle`: without a
style the default is still white in light and black in dark.

| | Without fix | With fix |
|---|---|---|
| `main` (4c74701) | First test fails: White instead of Red | Both
pass; Controls.Core.UnitTests 6735 passed |

### Issues Fixed

Fixes dotnet#9736

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Revert dotnet#39839 on `main` as requested. This restores the previous
behavior: a `Style` cannot override the default
`Shell.FlyoutBackgroundColor` binding until the candidate fix is
forwarded to `main`.

The identical implementation and regression tests are already on
`candidate/11.0.1xx-sr2`, where they were included in dotnet#40170 (commit
`706b461e9296fd30f7ff3c057dacf2025d60a698`). A separate candidate PR for
the same patch would be empty, so this PR changes only `main`.

### Validation

- Verified the commit is the exact inverse of
`9291bfb20edde2cc822b8e2a110f63d2b3425e09`; both changed files match
their pre-fix blobs.
- `dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug
-p:IncludeIosTargetFrameworks=false
-p:IncludeAndroidTargetFrameworks=false
-p:IncludeMacCatalystTargetFrameworks=false
-p:IncludeWindowsTargetFrameworks=false
-p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false
--verbosity quiet` — passed.
- `dotnet test
src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj
--no-restore -c Debug -p:IncludeIosTargetFrameworks=false
-p:IncludeAndroidTargetFrameworks=false
-p:IncludeMacCatalystTargetFrameworks=false
-p:IncludeWindowsTargetFrameworks=false
-p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false
--filter 'FullyQualifiedName~AppThemeTests' --verbosity quiet` — passed:
15 tests before the revert and 13 after removal of the two reverted
tests.
- `dotnet test
src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj
--no-build --no-restore -c Debug -p:IncludeIosTargetFrameworks=false
-p:IncludeAndroidTargetFrameworks=false
-p:IncludeMacCatalystTargetFrameworks=false
-p:IncludeWindowsTargetFrameworks=false
-p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false
--filter 'FullyQualifiedName~ShellTests|FullyQualifiedName~StyleTests'
--verbosity quiet` — passed: 147 tests.
- With the two original regression tests temporarily retained against
the reverted implementation, `dotnet test
src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj
--no-restore -c Debug -p:IncludeIosTargetFrameworks=false
-p:IncludeAndroidTargetFrameworks=false
-p:IncludeMacCatalystTargetFrameworks=false
-p:IncludeWindowsTargetFrameworks=false
-p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false
--filter
'FullyQualifiedName~StyleSetsShellFlyoutBackgroundColor|FullyQualifiedName~ShellFlyoutBackgroundColorFollowsTheThemeWithoutAStyle'
--logger 'console;verbosity=normal'` — expected failure: the style test
received white instead of red; the default-theme test passed. The
temporarily retained tests were removed again before committing.
- The combined selection `dotnet test
src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj
--no-restore -c Debug -p:IncludeIosTargetFrameworks=false
-p:IncludeAndroidTargetFrameworks=false
-p:IncludeMacCatalystTargetFrameworks=false
-p:IncludeWindowsTargetFrameworks=false
-p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false
--filter
'FullyQualifiedName~AppThemeTests|FullyQualifiedName~ShellTests|FullyQualifiedName~StyleTests'
--verbosity quiet` failed
`CorrectDefaultRadioButtonThemeColorsInLightAndDarkModes` (159 passed, 1
failed). The same failure occurred with the original patch restored on
the unmodified `main` baseline (161 passed, 1 failed); the isolated
selections above pass.
- `dotnet format Microsoft.Maui.sln --no-restore --verify-no-changes
--include src/Controls/src/Core/Shell/Shell.cs
src/Controls/tests/Core.UnitTests/AppThemeTests.cs --exclude
Templates/src --exclude-diagnostics CA1822 --verbosity quiet` — passed.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Related to dotnet#9736; this revert intentionally restores the issue on
`main`.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community ✨ Community Contribution s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't Change Shell FlyoutBackgroundColor From a Theme Style File

4 participants