// -----------------------------------------------------------------------
//
// Copyright 2014 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
namespace Perspex
{
using System;
using System.Collections.Generic;
using System.Linq;
using Perspex.Controls;
using Perspex.Styling;
public static class LogicalExtensions
{
public static T FindControl(this ILogical control, string id) where T : Control
{
return control.GetLogicalDescendents()
.OfType()
.FirstOrDefault(x => x.Id == id);
}
public static IEnumerable GetLogicalDescendents(this ILogical control)
{
foreach (ILogical child in control.LogicalChildren)
{
yield return child;
foreach (ILogical descendent in child.GetLogicalDescendents())
{
yield return descendent;
}
}
}
}
}