I\'m looking for a way to find all controls on Window by their type,
for example: find all TextBoxes
, find all controls implementing specific i
Here is yet another, compact version, with the generics syntax:
public static IEnumerable FindLogicalChildren(DependencyObject obj) where T : DependencyObject
{
if (obj != null) {
if (obj is T)
yield return obj as T;
foreach (DependencyObject child in LogicalTreeHelper.GetChildren(obj).OfType())
foreach (T c in FindLogicalChildren(child))
yield return c;
}
}