LogicalTreeHelper LogicalTreeHelper LogicalTreeHelper LogicalTreeHelper Class

定義

提供靜態 Helper 方法來查詢邏輯樹狀中的物件。Provides static helper methods for querying objects in the logical tree.

public ref class LogicalTreeHelper abstract sealed
public static class LogicalTreeHelper
type LogicalTreeHelper = class
Public Class LogicalTreeHelper
繼承
LogicalTreeHelperLogicalTreeHelperLogicalTreeHelperLogicalTreeHelper

備註

LogicalTreeHelper類別提供的方法可讓您用來傳回物件的子集合, 或邏輯樹狀節點內的特定物件。The LogicalTreeHelper class provides methods that you can use to return child collections of objects, or specific objects from within subnodes of the logical tree. 不過, 您通常執行的大部分物件樹狀結構作業也會由或FrameworkElement FrameworkContentElement上的類似方法或屬性公開。However, most of the object tree operations that you typically perform are also exposed by similar methods or properties on FrameworkElement or FrameworkContentElement. 例如, 請嘗試下列動作:For example, try the following:

  • 不是呼叫靜態GetChildren方法, 它會傳回邏輯子物件的列舉值, 而是使用在內容模型中針對該物件公開的專用集合。Instead of calling the static GetChildren method, which returns an enumerator for the logical child objects, use the dedicated collection exposed in the content model for that object. 幾乎所有支援內容模型的物件都會公開一些包含子物件集合的屬性, 並直接在該集合上提供集合介面支援。Nearly all objects that support a content model expose some property that contains the collection of child objects, and provides collection interface support directly on that collection.

  • 請在特定物件上FindLogicalNode FrameworkElement.FindName呼叫或FrameworkContentElement.FindName方法, 而不是呼叫靜態方法, 藉由指定其名稱來取得子物件。Instead of calling the static FindLogicalNode method to obtain a child object by specifying its name, call the FrameworkElement.FindName or FrameworkContentElement.FindName method on specific objects.

LogicalTreeHelper最適用于您要以遞迴方式在多個層級上向上或向下移動邏輯樹狀結構的分析案例, 而且想要使用一致的方法來檢查各種父系或子物件。LogicalTreeHelper is most useful for analysis scenarios where you are traveling up or down the logical tree recursively through multiple levels, and want to use a consistent approach for examining the various parent or child objects. 在此情況下, 您可能會存取混合的內容模型, 而使用更多的內容模型特定 Api 將會太複雜。In this case, you might be accessing a mixture of content models, and using the more content-model specific APIs would be too complex.

方法

BringIntoView(DependencyObject) BringIntoView(DependencyObject) BringIntoView(DependencyObject) BringIntoView(DependencyObject)

嘗試將所要求的 UI 項目帶入檢視,同時對目標引發 RequestBringIntoView 事件以報告結果。Attempts to bring the requested UI element into view and raises the RequestBringIntoView event on the target in order to report the results.

FindLogicalNode(DependencyObject, String) FindLogicalNode(DependencyObject, String) FindLogicalNode(DependencyObject, String) FindLogicalNode(DependencyObject, String)

嘗試尋找並傳回具有指定之名稱的物件。Attempts to find and return an object that has the specified name. 搜尋將從指定的物件開始,並持續至邏輯樹狀結構的子節點。The search starts from the specified object and continues into subnodes of the logical tree.

GetChildren(DependencyObject) GetChildren(DependencyObject) GetChildren(DependencyObject) GetChildren(DependencyObject)

透過處理邏輯樹狀,傳回所指定物件的立即子物件集合。Returns the collection of immediate child objects of the specified object, by processing the logical tree.

GetChildren(FrameworkContentElement) GetChildren(FrameworkContentElement) GetChildren(FrameworkContentElement) GetChildren(FrameworkContentElement)

藉由處理邏輯樹狀結構,傳回指定之 FrameworkContentElement 的直接子物件集合。Returns the collection of immediate child objects of the specified FrameworkContentElement by processing the logical tree.

GetChildren(FrameworkElement) GetChildren(FrameworkElement) GetChildren(FrameworkElement) GetChildren(FrameworkElement)

藉由處理邏輯樹狀結構,傳回指定之 FrameworkElement 的直接子物件集合。Returns the collection of immediate child objects of the specified FrameworkElement by processing the logical tree.

GetParent(DependencyObject) GetParent(DependencyObject) GetParent(DependencyObject) GetParent(DependencyObject)

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

適用於