Skip to content

Commit

Permalink
fix: Restore the protected virtual OnChildrenChanged in Shape
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr.Rx committed Mar 16, 2020
1 parent 83eb321 commit 639eb8c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Uno.UI/UI/Xaml/BatchCollectionWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public abstract partial class BatchCollection<T> : ICollection<T>, IEnumerable<T
{
private readonly DependencyObject _owner;

/// <summary>
/// The owner of this collection.
/// This is intended to be used to redispatch to a specific instance in ** static ** CollectionChanged handlers.
/// </summary>
internal DependencyObject Owner => _owner;

public BatchCollection(DependencyObject owner)
{
_owner = owner;
Expand Down
13 changes: 13 additions & 0 deletions src/Uno.UI/UI/Xaml/Shapes/Shape.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ partial class Shape
protected Shape() : base("svg", isSvg: true)
{
SvgChildren = new UIElementCollection(this);
SvgChildren.CollectionChanged += OnSvgChildrenChanged;

OnStretchUpdatedPartial();
}
Expand All @@ -43,6 +44,18 @@ protected void InitCommonShapeProperties() // Should be called from base class c

protected abstract SvgElement GetMainSvgElement();

private static readonly NotifyCollectionChangedEventHandler OnSvgChildrenChanged = (object sender, NotifyCollectionChangedEventArgs args) =>
{
if (sender is UIElementCollection children && children.Owner is Shape shape)
{
shape.OnChildrenChanged();
}
};

protected virtual void OnChildrenChanged()
{
}

partial void OnFillUpdatedPartial()
{
UpdateHitTest();
Expand Down

0 comments on commit 639eb8c

Please sign in to comment.