LogicalTreeHelper.GetParent(DependencyObject) 方法

定義

藉由處理邏輯樹狀結構,傳回指定之物件的父物件。Returns the parent object of the specified object by processing the logical tree.

public:
 static System::Windows::DependencyObject ^ GetParent(System::Windows::DependencyObject ^ current);
public static System.Windows.DependencyObject GetParent (System.Windows.DependencyObject current);
static member GetParent : System.Windows.DependencyObject -> System.Windows.DependencyObject
Public Shared Function GetParent (current As DependencyObject) As DependencyObject

參數

current
DependencyObject

要尋找父物件的物件。The object to find the parent object for. 這個物件應該是 FrameworkElementFrameworkContentElementThis is expected to be either a FrameworkElement or a FrameworkContentElement.

傳回

要求的父物件。The requested parent object.

備註

這個方法只是可取得FrameworkElement FrameworkElement.ParentFrameworkContentElement.Parent屬性之適當類型版本 (或FrameworkContentElement) 的包裝函式, 因此除非您無法判斷current類型, 否則您可能會想要檢查各自的改為實例屬性。This method is merely a wrapper that gets the appropriate type version (FrameworkElement or FrameworkContentElement) of the FrameworkElement.Parent or FrameworkContentElement.Parent property; so unless you are unable to determine the current type, you might want to check the respective instance properties instead.

適用於