markus / ConvertService / ServiceController / Markus.Service.StationController / Extensions / VisualTreeHelper.cs @ 5c387707
이력 | 보기 | 이력해설 | 다운로드 (707 Bytes)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Threading.Tasks; |
6 |
using System.Windows; |
7 |
|
8 |
namespace Markus.Service |
9 |
{ |
10 |
public static class VisualTreeHelperEx |
11 |
{ |
12 |
public static IEnumerable<T> FindLogicalChildren<T>(DependencyObject obj) where T : DependencyObject |
13 |
{ |
14 |
if (obj != null) |
15 |
{ |
16 |
if (obj is T) |
17 |
yield return obj as T; |
18 |
|
19 |
foreach (DependencyObject child in LogicalTreeHelper.GetChildren(obj).OfType<DependencyObject>()) |
20 |
foreach (T c in FindLogicalChildren<T>(child)) |
21 |
yield return c; |
22 |
} |
23 |
} |
24 |
} |
25 |
} |