Repository navigation
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 39839Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 39839" |
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
/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
d51dedd to
520e114
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit 520e114.
PR Test Gate
🧪 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
Execution log excerptsWithout fix With fix PR head: 520e1141. Without-fix baseline: b4f1d314. |
There was a problem hiding this comment.
🟢 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
AppThemeBindingat 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
### 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>
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>
### 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>
### 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>
<!-- 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>
### 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>
<!-- 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>
### 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>
<!-- 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>
Description of Change
Shell.FlyoutBackgroundColorset from aStyle, implicit or explicit, was ignored. Only a value set directly on theShellworked, andFlyoutBackgroundworked from aStyle.Root cause
The
Shellconstructor bindsFlyoutBackgroundColorto anAppThemeBindingfor the default white/black colors. It uses the publicSetBinding, which applies the binding withSetterSpecificity.FromBinding, and a binding outranks everyStylesetter; only a value set directly on the element is higher. So the default always won over aStyle.Fix
The default binding is applied with the lowest specificity,
new SetterSpecificity(), through the same internal overloadSetteruses for bindings in styles. AStylesetter or a value set directly on theShellnow 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 implicitShellstyle 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.main(4c74701)Issues Fixed
Fixes #9736