找控件的父类

 1  private TestTabControl TabControlParent
 2         {
 3             get
 4             {
 5                 TestTabControl parent = base.Parent as TestTabControl;
 6                 if (parent != null)
 7                 {
 8                     return parent;
 9                 }
10                 for (DependencyObject obj2 = this; obj2 != null; obj2 = VisualTreeHelper.GetParent(obj2))
11                 {
12                     TestTabControl control2 = obj2 as TestTabControl;
13                     if (control2 != null)
14                     {
15                         return control2;
16                     }
17                 }
18                 return null;
19             }
20         }

 

posted @ 2013-09-11 11:44  法的空间  阅读(241)  评论(0编辑  收藏  举报