Skip to content

Conversation

@NirmalKumarYuvaraj
Copy link
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 the community ✨ Community Contribution label Sep 26, 2025
@dotnet-policy-service
Copy link
Contributor

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

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label 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
Copy link
Contributor

Copilot AI left a comment

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

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@jsuarezruiz jsuarezruiz left a comment

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
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
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@jsuarezruiz jsuarezruiz left a comment

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
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
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
Contributor

/azp run

@azure-pipelines
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants