Check in SilverlightSpy. Use Cotrol+Shift+Mouse Over to find it and look at
the Visualtree, then use one of the GetChildren overloads in this class to
find it


public
static class VisualTreeExtensions

{

public static IEnumerable<DependencyObject> GetChildren(this
DependencyObject depObject)

{

int count = depObject.GetChildrenCount();

for (int i = 0; i < count; i++)

{

yield return VisualTreeHelper.GetChild(depObject, i);

}

}

public static DependencyObject GetChild(this DependencyObject
depObject, intchildIndex)

{

return VisualTreeHelper.GetChild(depObject, childIndex);

}

public static DependencyObject GetChild(this DependencyObject depObject,
string name)

{

return depObject.GetChild(name, false);

}

public static DependencyObject GetChild(this DependencyObject depObject,
string name, bool recursive)

{

foreach (var child in depObject.GetChildren())

{

var element = child as FrameworkElement;

if (element != null)

{

if (element.Name == name) // If its a FrameworkElement check Name

return element;

var innerElement = element.FindName(name) as DependencyObject; // Try to get
it using FindByName might be more efficient

if (innerElement != null)

return innerElement;

}

if (recursive) // If it's recursive search through its children

{

var innerChild = child.GetChild(name, recursive);

if (innerChild != null)

return innerChild;

}

}

return null;

}

public static IEnumerable<TypeToLookFor> GetChildren<TypeToLookFor>(this
DependencyObject depObject, bool recursive)

where TypeToLookFor : class

{

List<TypeToLookFor> types = new List<TypeToLookFor>();

foreach (var child in depObject.GetChildren())

{

var found = child as TypeToLookFor;

if (found != null)

types.Add(found);

else if (recursive) // If it's recursive search through its children only if
it wasnt the type we were looking for

types.AddRange(child.GetChildren<TypeToLookFor>(recursive));

}

return types;

}

public static int GetChildrenCount(this DependencyObject depObject)

{

return VisualTreeHelper.GetChildrenCount(depObject);

}

public static DependencyObject GetParent(this DependencyObject depObject)

{

return VisualTreeHelper.GetParent(depObject);

}

public static T GetParent<T>(this DependencyObject depObject)

where T: DependencyObject

{

var parent = depObject.GetParent();

if(parent ==null || parent is T)

return parent as T;

return parent.GetParent<T>();

}

}



-- 
Miguel A. Madero Reyes
www.miguelmadero.com (blog)
[email protected]
_______________________________________________
ozsilverlight mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight

Reply via email to