根据Frame.Content获取Frame

public static T GetParent<T>(DependencyObject child) where T : DependencyObject
        {
            DependencyObject dependencyObject = VisualTreeHelper.GetParent(child);
            if (dependencyObject != null)
            {
                T parent = dependencyObject as T;
                if (parent != null)
                {
                    return parent;
                }
                else
                {
                    return GetParent <T>(dependencyObject);
                }
            }
            else
            {
                return null;
            }
        }

链接

posted @ 2014-09-18 08:15  cg.2019  阅读(208)  评论(0编辑  收藏  举报