Boogaart.Silverlight.Behaviors.Popup.FindHighestAncestor C# (CSharp) Method

FindHighestAncestor() private static method

private static FindHighestAncestor ( System.Windows.Controls.Primitives popup ) : FrameworkElement
popup System.Windows.Controls.Primitives
return System.Windows.FrameworkElement
        private static FrameworkElement FindHighestAncestor(Windows.Popup popup)
        {
            var ancestor = (FrameworkElement)popup;

            while (true)
            {
                var parent = VisualTreeHelper.GetParent(ancestor) as FrameworkElement;

                if (parent == null)
                {
                    return ancestor;
                }

                ancestor = parent;
            }
        }