Initial commit.
This commit is contained in:
38
Wino.Mail/Helpers/WinoVisualTreeHelper.cs
Normal file
38
Wino.Mail/Helpers/WinoVisualTreeHelper.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace Wino.Helpers
|
||||
{
|
||||
public static class WinoVisualTreeHelper
|
||||
{
|
||||
public static T GetChildObject<T>(DependencyObject obj, string name) where T : FrameworkElement
|
||||
{
|
||||
DependencyObject child = null;
|
||||
T grandChild = null;
|
||||
|
||||
for (int i = 0; i <= VisualTreeHelper.GetChildrenCount(obj) - 1; i++)
|
||||
{
|
||||
child = VisualTreeHelper.GetChild(obj, i);
|
||||
|
||||
if (child is T && (((T)child).Name == name | string.IsNullOrEmpty(name)))
|
||||
{
|
||||
return (T)child;
|
||||
}
|
||||
else
|
||||
{
|
||||
grandChild = GetChildObject<T>(child, name);
|
||||
}
|
||||
if (grandChild != null)
|
||||
{
|
||||
return grandChild;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user