30 lines
780 B
C#
30 lines
780 B
C#
using System.Collections.Generic;
|
|
using System.Windows;
|
|
|
|
namespace AnotherReplayReader.Utils
|
|
{
|
|
internal static class WpfExtensions
|
|
{
|
|
public static IEnumerable<T> FindVisualChildren<T>(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<T>(child))
|
|
{
|
|
yield return childOfChild;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|