Skip to content

[NET11.0] Provided Fill property support for BoxView control#31789

Merged
jfversluis merged 10 commits into
dotnet:net11.0from
NirmalKumarYuvaraj:fix-2365
May 5, 2026
Merged

[NET11.0] Provided Fill property support for BoxView control#31789
jfversluis merged 10 commits into
dotnet:net11.0from
NirmalKumarYuvaraj:fix-2365

Conversation

@NirmalKumarYuvaraj

Copy link
Copy Markdown
Contributor

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

This pull request adds support for the Fill property to the BoxView control, allowing it to be filled with any Brush (including gradients), not just a solid color. It introduces the necessary property, binding, event handling, and updates to tests and sample code to demonstrate and validate the new functionality.

The most important changes are:

BoxView Fill Property Implementation:

  • Added a new bindable property FillProperty and corresponding Fill getter/setter to BoxView, enabling the use of any Brush (such as gradients) to fill the box. The property includes logic to manage event subscriptions for brush changes and resource updates. (src/Controls/src/Core/BoxView/BoxView.cs) [1] [2] [3] [4]
  • Updated the implementation of the IShapeView.Fill property to prioritize the new Fill property over the existing Color property. (src/Controls/src/Core/BoxView/BoxView.cs)

Event Handling and Resource Management:

  • Introduced the WeakBrushChangedProxy helper class to manage weak event subscriptions for brush property changes, ensuring proper resource cleanup and preventing memory leaks. (src/Controls/src/Core/Internals/WeakEventProxy.cs, moved from src/Controls/src/Core/Shapes/Shape.cs) [1] [2]
  • Ensured event handlers and resource listeners are added/removed as the Fill property changes, and cleaned up in the BoxView destructor. (src/Controls/src/Core/BoxView/BoxView.cs) [1] [2]

Public API Updates:

  • Registered the new Fill property and its accessors in the public API files for all supported platforms. [1] [2] [3] [4] [5] [6]

Test and Sample Enhancements:

  • Updated the BoxView sample view model and test page to support and demonstrate the new Fill property, including options for solid, linear, and radial gradient fills, and corresponding UI controls. (src/Controls/tests/TestCases.HostApp/FeatureMatrix/BoxView/BoxViewControlPage.xaml, src/Controls/tests/TestCases.HostApp/FeatureMatrix/BoxView/BoxViewViewModel.cs) [1] [2] [3] [4] [5]

Code Cleanup:

  • Removed the unused System.ComponentModel import and relocated the WeakBrushChangedProxy class from Shape.cs to a more appropriate location. (src/Controls/src/Core/BoxView/BoxView.cs, src/Controls/src/Core/Shapes/Shape.cs) [1] [2]

Issues Fixed

Fixes #2365

@dotnet-policy-service dotnet-policy-service Bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Sep 26, 2025
@sheiksyedm sheiksyedm added the area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing label Sep 26, 2025
@NirmalKumarYuvaraj
NirmalKumarYuvaraj marked this pull request as ready for review September 26, 2025 12:12
Copilot AI review requested due to automatic review settings September 26, 2025 12:12

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.

Pull Request Overview

This PR adds support for the Fill property to the BoxView control, enabling it to be filled with any Brush (including gradients) instead of just solid colors. The implementation includes proper event handling, resource management, and comprehensive test coverage.

  • Adds a new Fill property to BoxView that accepts any Brush type
  • Implements proper event subscription and resource management for brush changes
  • Updates the IShapeView.Fill implementation to prioritize the new Fill property over the existing Color property

Reviewed Changes

Copilot reviewed 13 out of 23 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Controls/src/Core/BoxView/BoxView.cs Core implementation of the Fill property with event handling and resource management
src/Controls/src/Core/Internals/WeakEventProxy.cs Adds WeakBrushChangedProxy class for managing brush change subscriptions
src/Controls/src/Core/Shapes/Shape.cs Removes duplicate WeakBrushChangedProxy class
src/Controls/src/Core/PublicAPI/*/PublicAPI.Unshipped.txt Updates public API surface for all platforms
src/Controls/tests/TestCases.HostApp/FeatureMatrix/BoxView/BoxViewViewModel.cs Adds view model support for Fill property with gradient brushes
src/Controls/tests/TestCases.HostApp/FeatureMatrix/BoxView/BoxViewControlPage.xaml Updates UI test page with Fill property binding and controls
src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/BoxViewFeatureTests.cs Adds new UI tests for Fill property functionality

Comment thread src/Controls/src/Core/BoxView/BoxView.cs Outdated
@jsuarezruiz

Copy link
Copy Markdown
Contributor

/azp run MAUI-UITests-public

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@jsuarezruiz jsuarezruiz 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.

Several tests failing on Android:
image
Around 7-8% difference between snapshots. Could you take a look?

@NirmalKumarYuvaraj

Copy link
Copy Markdown
Contributor Author

Several tests failing on Android: image Around 7-8% difference between snapshots. Could you take a look?

@jsuarezruiz , I have added the pending snaps for android and mac platforms. There was a issue with windows platform , it does not have anything to do with this PR. it was related to shadow (#31821). Fill is working fine in windows also. attaching images for reference.

Solid Linear Radial
image image image

@jsuarezruiz

Copy link
Copy Markdown
Contributor

/azp run MAUI-UITests-public

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@jsuarezruiz jsuarezruiz 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.

Pending snapshot on Windows.

BoxView_CornerRadiusWithOpacityAndShadow
image

@jsuarezruiz

Copy link
Copy Markdown
Contributor

Pending snapshot on Windows.

BoxView_CornerRadiusWithOpacityAndShadow image

Not related with the changes from this PR, but the Shadow not follow the BoxView corners radius.

@NirmalKumarYuvaraj

Copy link
Copy Markdown
Contributor Author

Pending snapshot on Windows.
BoxView_CornerRadiusWithOpacityAndShadow image

Not related with the changes from this PR, but the Shadow not follow the BoxView corners radius.

@jsuarezruiz , yeah need to restrict this test case too.

@jsuarezruiz

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 3 pipeline(s).

PathAspect IShapeView.Aspect => PathAspect.None;

Paint? IShapeView.Fill => Color?.AsPaint();
Paint? IShapeView.Fill => Fill ?? Color?.AsPaint();

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.

The implementation allows both Color and Fill to be set simultaneously, with Fill taking priority. This requires updates in the documentation.

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.

Also, what happens when Fill is cleared?
<BoxView x:Name="box" Color="Red" Fill="{StaticResource MyGradient}" />

Later in code:

box.Fill = null;

Does Red color suddenly appear? Could we have a test?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jsuarezruiz , when fill is set to null , the color takes over. i have added test case to ensure this.

@kubaflo

kubaflo commented Mar 22, 2026

Copy link
Copy Markdown
Collaborator

@jfversluis do you think it makes sense to add to net11 given that you can use border instead of boxView?

@github-actions

github-actions Bot commented Mar 26, 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 -- 31789

Or

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

@Tamilarasan-Paranthaman
Tamilarasan-Paranthaman changed the base branch from net10.0 to net11.0 March 26, 2026 06:24
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman changed the title Provided Fill property support for BoxView control [NET11.0] Provided Fill property support for BoxView control Mar 26, 2026
@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-win AI found a better alternative fix than the PR s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) labels Mar 29, 2026
@kubaflo

kubaflo commented Apr 26, 2026

Copy link
Copy Markdown
Collaborator

@jfversluis the PR looks good, but I'm not sure if this feature is necessary. What do you think?

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Expert Review — 6 findings

See inline comments for details.

@kubaflo kubaflo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you please review the AI's suggestions?

@dotnet dotnet deleted a comment from MauiBot May 1, 2026
@dotnet dotnet deleted a comment from MauiBot May 1, 2026
@dotnet dotnet deleted a comment from MauiBot May 1, 2026
@dotnet dotnet deleted a comment from MauiBot May 1, 2026
@dotnet dotnet deleted a comment from MauiBot May 1, 2026
@dotnet dotnet deleted a comment from MauiBot May 1, 2026
@dotnet dotnet deleted a comment from MauiBot May 1, 2026
@MauiBot

MauiBot commented May 1, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Merge Conflict Detected — This PR has merge conflicts with its target branch. Please rebase onto the target branch and resolve the conflicts.

@NirmalKumarYuvaraj

Copy link
Copy Markdown
Contributor Author

@kubaflo , Failures are unrelated. All box view test cases are passed.

@kubaflo

kubaflo commented May 5, 2026

Copy link
Copy Markdown
Collaborator

@jfversluis this PR is good to go to net11 if we want this feature

@jfversluis
jfversluis merged commit 754ba13 into dotnet:net11.0 May 5, 2026
191 of 211 checks passed
@github-actions github-actions Bot added this to the .NET 11.0-preview4 milestone May 5, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

🚨 API change(s) detected @davidbritch FYI

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

🚨 API change(s) detected @davidortinau FYI

jfversluis pushed a commit that referenced this pull request May 11, 2026
This pull request introduces a small but important change to the
`WebViewEvaluateJavaScriptReturnsCorrectResults` test method by adding a
call to `VerifyInternetConnectivity()` at the beginning of the test.
This ensures that the test only proceeds if there is an active internet
connection, which can help prevent false negatives due to connectivity
issues.

* Added a call to `VerifyInternetConnectivity()` at the start of the
`WebViewEvaluateJavaScriptReturnsCorrectResults` test in `Issue20288.cs`
to ensure the test only runs when internet access is available.
* Re-saved the correct iOS 18 images for BoxViewFeatureTests due to
wrong images being re-saved in this PR:
#31789.
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-win AI found a better alternative fix than the PR s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) t/breaking 💥

Projects

None yet

Development

Successfully merging this pull request may close these issues.