FindName in Silverlight --- Walk through the viual tree

How do you obtain a reference to an ancestor (within the visual tree) of a Silverlight FrameworkElement, given its name?  The question seems pretty straight forward.  FrameworkElement exposes a method, aptly named FindName, which appears to do just that.  Easy solution, right?  Well....maybe.


Using the FindName method works great, as long as the object you're looking for resides within the same XAML namescope as the FrameworkElement.  How do you know if your target object is in the same XAML namescope as your FrameworkElement? 


After my research, i found if the control is inside the usercontrols which you are referencing, these kind of controls will not be found by FindName method. While if the target object you are looking for is in the same level of the XAML, they can be found.


However, they are still part of the visual tree, so there should be some way to walk the tree down.  FrameworkElement doesn't appear to expose any members to facilitate this type of action.  Still, there must be a way to do it


I found a method somewhere for this solution, It will find the object regardless of the XAML namescope.


想对作者说点什么? 我来说一句