1

我需要一个函数来返回可以是 System.Windows.Controls.Control 或 System.Windows.Controls.StackPanel 的东西。

理想情况下,它应该是由两者实现的接口或它们的基类(我讨厌为此目的使用对象)

UIElement 等之类的东西似乎只属于其中一个。

有任何想法吗?

4

2 回答 2

3

FrameworkElement看起来是您唯一的选择。

于 2011-06-24T08:45:14.190 回答
0

FrameworkElement 是最接近两者的祖先,但任何高于此的都可以(包括 UIElement):

System.Object 
  System.Windows.Threading.DispatcherObject
    System.Windows.DependencyObject
      System.Windows.Media.Visual
        System.Windows.UIElement
          System.Windows.FrameworkElement
            System.Windows.Controls.Panel
              System.Windows.Controls.StackPanel

System.Object 
  System.Windows.Threading.DispatcherObject
    System.Windows.DependencyObject
      System.Windows.Media.Visual
        System.Windows.UIElement
          System.Windows.FrameworkElement
            System.Windows.Controls.Control
于 2011-06-24T08:52:23.320 回答