-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Points collection observability support for Polygon and Polyline #15030
Add Points collection observability support for Polygon and Polyline #15030
Conversation
Can you add a simple unit test for this scenario? |
@maxkatz6 done |
@SKProCH ok... I have checked a little, and noticed that change notification should have already been working with this code: But as you can see, it only supported IAvaloniaList. So, this PR should instead fix PolylineGeometry/PolygonGeometry not respecting INotifyCollectionChanged. |
The problem with this geometry is under the hood implementation. We create a new Points collection inside geometry ctor: Avalonia/src/Avalonia.Base/Media/PolylineGeometry.cs Lines 46 to 48 in 4c949ee
Points its just a sealed inheritor of AvaloniaList: Avalonia/src/Avalonia.Base/Points.cs Lines 6 to 16 in 4c949ee
But as we can see inside AvaloniaList's ctor, it copying collection content from the collection parameter: Avalonia/src/Avalonia.Base/Collections/AvaloniaList.cs Lines 76 to 79 in 4c949ee
So, at the moment where we create an Points collection inside of Geometry ctor we just copying the elements of the original collection, and we don't have reference to original collection and the changes doesn't propagated to the Points. It's actually has the same effect if we just call .ToList() to original collection. So, currently there is no actual benefits of changing OnPointsChanged implementation as you suggest. |
You can test this PR using the following package version. |
Try to replace
with
|
You can test this PR using the following package version. |
You can test this PR using the following package version. |
Actually some of tests failing, i'll fix that a little later |
You can test this PR using the following package version. |
You can test this PR using the following package version. |
You can test this PR using the following package version. |
…15030) * Add Points binding observability support for Polygon and Polyline * Add simple tests for Polygon and Polyline Points updating * Revert "Add Points binding observability support for Polygon and Polyline" This reverts commit e16d987. * Move Geometry.Changed handler to Shape class to make it available to all inheritors * Fixes the event subscriptions * Fix tests * Add memory leak tests
What does the pull request do?
Add Points binding observability support for Polygon and Polyline
What is the current behavior?
When ObservableCollection was bound to Points property, updating collection does not updates the geometry. See #3623
What is the updated/expected behavior with this PR?
When ObservableCollection was bound to Points property, updating collection updates the geometry (and control actially re-rendered with a new geometry)
Checklist
Breaking changes
None
Fixed issues
Fixes #3623