private static bool ShouldContinueTreeWalk()

in src/BehaviorsSDKManaged/Microsoft.Xaml.Interactivity/VisualStateUtilities.cs [119:140]


        private static bool ShouldContinueTreeWalk(FrameworkElement element)
        {
            if (element == null)
            {
                return false;
            }
            else if (element is UserControl)
            {
                return false;
            }
            else if (element.Parent == null)
            {
                // Stop if parent's parent is null AND parent isn't the template root of a ControlTemplate or DataTemplate.
                FrameworkElement templatedParent = VisualTreeHelper.GetParent(element) as FrameworkElement;
                if (templatedParent == null || (!(templatedParent is Control) && !(templatedParent is ContentPresenter)))
                {
                    return false;
                }
            }

            return true;
        }