I can not add a comment. So, I want to add information to the previous comment. Of course, in my example, I cannot use OnVisualChildrenChanged or ArrangeOverride.
I have a cach list with previous children:
private readonly List<UIElement> _elements = new List<UIElement>();
I am signing an event that fires when a property is changed - LayoutUpdated. In the event handler:
if (_canvas == null) return; var children = _canvas.Children.OfType<UIElement>().ToList(); if (_elements.SequenceEqual(children)) return; var removeElements = _elements.Except(children); var newelements = children.Except(_elements); _elements.AddRange(newelements);
Smagin alexey
source share