[Controls][Net11][WIP]VisualElement: Obsolete BackgroundColor in favor of Background - #36130
[Controls][Net11][WIP]VisualElement: Obsolete BackgroundColor in favor of Background#36130KarthikRajaKalaimani wants to merge 47 commits into
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 36130Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 36130" |
|
Hey there @@KarthikRajaKalaimani! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
/azp run maui-pr-uitests , maui-pr-devicetests |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
31ec74e to
ef245cd
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run maui-pr-uitests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This comment has been minimized.
This comment has been minimized.
MauiBot
left a comment
There was a problem hiding this comment.
Expert Review — 2 findings
See inline comments for details.
|
@jfversluis could you please have a look? |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Preserve BackgroundImageSource precedence over implicit styles, keep the TitleBar compatibility bridge active after reattachment, and scope obsolete warnings in device tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 51b16329-8bf7-4952-960e-d9e9313e204d
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
/azp run maui-pr-devicetests |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
/azp run maui-pr-devicetests |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 51b16329-8bf7-4952-960e-d9e9313e204d
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
kubaflo
left a comment
There was a problem hiding this comment.
Why it has the label do-not-merge?
We plan to include this in .NET 12 as part of the full migration from BackgroundColor to the Background property across all source files. |
This comment has been minimized.
This comment has been minimized.
|
|
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 from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
VisualElement.BackgroundColoroverlaps withBackground, which already supports solid colors through the implicitColortoSolidColorBrushconversion and also supports gradient brushes. Maintaining both APIs has caused mapper and control behavior to diverge.This change marks the legacy color APIs obsolete in favor of their brush-based replacements:
VisualElement.BackgroundColorandBackgroundColorProperty->BackgroundandBackgroundPropertyIBorderElement.BackgroundColorandIsBackgroundColorSet()->BackgroundandIsBackgroundSet()VisualElement.MapBackgroundColor()->MapBackground()Existing applications remain runtime-compatible. Values set through
BackgroundColorstill flow throughIView.Background, and the legacy mapper entry remains available while forwarding toMapBackground.Implementation Details
Background.RadioButtonandTitleBartemplate bindings that must continue reacting to the obsolete property.Page.BackgroundImageSourcebehavior: a locally set image can override an implicitPage.Backgroundstyle, while an equally specific or localBackgroundkeeps its existing precedence.TitleBarproperty-change bridge active when the same title bar is detached and reattached.CS0618suppression. Framework-owned test setup now usesBackground; tests intentionally validatingBackgroundColoruse scoped pragmas.net11.0device tests:FragmentManagerretains ownership of its wrapper fragment, and the test host now waits for fragment destruction before starting the next test.Tests
BackgroundImageSource.TitleBarbridge notifications after detach/reattach.Migration Guide
view.BackgroundColor = Colors.Red;view.Background = Colors.Red;<Label BackgroundColor="Red" /><Label Background="Red" />VisualElement.MapBackgroundColor(handler, view);VisualElement.MapBackground(handler, view);Compatibility Guidance
Do not suppress
CS0618for an entire project. Framework code should migrate toBackground; scoped suppressions should be limited to compatibility paths and tests that intentionally exercise the obsolete API.Issues Fixed
Fixes #28854