using System; using System.Collections; using System.Collections.Generic; using System.Windows; using System.Windows.Controls; namespace BS.Shared.Extensions { public static class UIElementCollectionExtensions { public static void RemoveRange(this UIElementCollection pList, IEnumerable pToRemove) { foreach (UIElement iItem in pToRemove) { pList.Remove(iItem); } } public static void RemoveRange(this UIElementCollection pList, int pStartIndex) { if (pList.Count > pStartIndex) { pList.RemoveRange(pStartIndex, pList.Count - pStartIndex); } } public static void RemoveRange(this UIElementCollection pList, Predicate pMatch) { List lToDelete = new List(); foreach (UIElement iElement in pList) { if (pMatch(iElement)) { lToDelete.Add(iElement); } } pList.RemoveRange(lToDelete); } } }