/// <summary> /// Starts or stops monitoring of the AssociatedObject's logical children. /// </summary> /// <param name="add"></param> private void AddOrRemoveLogicalChildren(bool add) { if (_window != null && _window.IsInitialized) { AddOrRemoveSizeChangedHandlers(false); _elements.Clear(); if (add) { _elements.AddRange(VisualHelper.FindLogicalChildren <FrameworkElement>(this.AssociatedObject)); } _elements.Add(this.AssociatedObject); AddOrRemoveSizeChangedHandlers(true); } }