找控件的父类
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 }