public static T FindParent <T>(this UIElement control) where T : UIElement
    {
        UIElement p = VisualTreeHelper.GetParent(control) as UIElement;

        if (p != null)
        {
            if (p is T)
            {
                return(p as T);
            }
            else
            {
                return(ControlFinder.FindParent <T>(p));
            }
        }
        return(null);
    }