public static void FindUpInTree(List<FrameworkElement> lst, Visual parent, Visual ignore, IFinderMatchVisualHelper helper)
{
// First thing to do is find Down in the existing node...
//FindDownInTree(lst, parent, ignore, helper);
if (helper.DoesMatch(parent))
{
lst.Add(parent as FrameworkElement);
}
// Ok, now check to see we are not at a stop.. i.e. got it.
if (lst.Count > 0 && helper.StopAfterFirst)
{
// Hum, don't think we need to do anything here: yet.
}
else
{
// Ok, now try to get a new parent...
FrameworkElement feCast = parent as FrameworkElement;
if (feCast != null)
{
FrameworkElement feNewParent = feCast.Parent as FrameworkElement;
if (feNewParent == null || feNewParent == feCast)
{
// Try to get the templated parent
feNewParent = feCast.TemplatedParent as FrameworkElement;
}
// Now check to see that we have a valid parent
if (feNewParent != null && feNewParent != feCast)
{
// Pass up
FindUpInTree(lst, feNewParent, feCast, helper);
}
}
}
}