using System.Collections.Generic; using System.Windows; namespace AnotherReplayReader.Utils { internal static class WpfExtensions { public static IEnumerable FindVisualChildren(this DependencyObject depObj) where T : DependencyObject { foreach (var x in LogicalTreeHelper.GetChildren(depObj)) { if (x is not DependencyObject child) { continue; } if (child is T tchild) { yield return tchild; } foreach (var childOfChild in FindVisualChildren(child)) { yield return childOfChild; } } } } }