Skip to content

Commit

Permalink
fix(skia): Fix support for UIElementCollection item replace
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Dec 16, 2021
1 parent 5716a96 commit bd22523
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/Uno.UI/UI/Xaml/UIElement.skia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ internal bool RemoveChild(UIElement child)
}
}

internal UIElement ReplaceChild(int index, UIElement child)
{
var previous = _children[index];
RemoveChild(previous);
AddChild(child, index);

return previous;
}

internal void ClearChildren()
{
foreach (var child in _children.ToArray())
Expand Down
6 changes: 4 additions & 2 deletions src/Uno.UI/UI/Xaml/UIElementCollection.netstd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ private View RemoveAtCore(int index)
return item;
}

private bool RemoveCore(View item) => _owner.RemoveChild(item);
private bool RemoveCore(View item)
=> _owner.RemoveChild(item);

private View SetAtIndexCore(int index, View value) => throw new NotImplementedException();
private View SetAtIndexCore(int index, View value)
=> _owner.ReplaceChild(index, value);
}
}

0 comments on commit bd22523

Please sign in to comment.