file scoped namespaces (#565)
This commit is contained in:
@@ -2,51 +2,50 @@
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace Wino.Helpers
|
||||
namespace Wino.Helpers;
|
||||
|
||||
public static class WinoVisualTreeHelper
|
||||
{
|
||||
public static class WinoVisualTreeHelper
|
||||
public static T GetChildObject<T>(DependencyObject obj, string name) where T : FrameworkElement
|
||||
{
|
||||
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++)
|
||||
{
|
||||
DependencyObject child = null;
|
||||
T grandChild = null;
|
||||
child = VisualTreeHelper.GetChild(obj, i);
|
||||
|
||||
for (int i = 0; i <= VisualTreeHelper.GetChildrenCount(obj) - 1; i++)
|
||||
if (child is T && (((T)child).Name == name | string.IsNullOrEmpty(name)))
|
||||
{
|
||||
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 (T)child;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IEnumerable<T> FindDescendants<T>(this DependencyObject depObj) where T : DependencyObject
|
||||
{
|
||||
if (depObj != null)
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
|
||||
{
|
||||
var child = VisualTreeHelper.GetChild(depObj, i);
|
||||
if (child != null && child is T)
|
||||
{
|
||||
yield return (T)child;
|
||||
}
|
||||
grandChild = GetChildObject<T>(child, name);
|
||||
}
|
||||
if (grandChild != null)
|
||||
{
|
||||
return grandChild;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (T childOfChild in FindDescendants<T>(child))
|
||||
{
|
||||
yield return childOfChild;
|
||||
}
|
||||
public static IEnumerable<T> FindDescendants<T>(this DependencyObject depObj) where T : DependencyObject
|
||||
{
|
||||
if (depObj != null)
|
||||
{
|
||||
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
|
||||
{
|
||||
var child = VisualTreeHelper.GetChild(depObj, i);
|
||||
if (child != null && child is T)
|
||||
{
|
||||
yield return (T)child;
|
||||
}
|
||||
|
||||
foreach (T childOfChild in FindDescendants<T>(child))
|
||||
{
|
||||
yield return childOfChild;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user