找控件的父类

复制代码
 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 @   法的空间  阅读(245)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示