-
Notifications
You must be signed in to change notification settings - Fork 0
/
Helpers.cs
36 lines (31 loc) · 927 Bytes
/
Helpers.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Windows;
using System.Windows.Media;
using LiteDB;
namespace Kanaban
{
public static class WPFEx
{
public static T GetChildOfType<T>(this DependencyObject depObj)
where T : DependencyObject
{
if (depObj == null) return null;
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
{
var child = VisualTreeHelper.GetChild(depObj, i);
var result = (child as T) ?? GetChildOfType<T>(child);
if (result != null) return result;
}
return null;
}
public static void Foreach<T>(this LiteCollection<T> col , Action<T> ac)
{
var en = col.FindAll().GetEnumerator();
while (en.MoveNext())
{
ac.Invoke(en.Current);
}
en.Dispose();
}
}
}