FrameworkContentElement.AddLogicalChild(Object) 方法


加入所提供的項目作為這個項目的子項目。Adds the provided element as a child of this element.

protected public:
 void AddLogicalChild(System::Object ^ child);
protected internal void AddLogicalChild (object child);
member this.AddLogicalChild : obj -> unit
Protected Friend Sub AddLogicalChild (child As Object)



要加入的子項目。The child element to be added.


如果在另一個進程反覆運算邏輯樹狀結構時呼叫,這個方法可能會擲回例外狀況。This method can throw an exception if called at a time when the logical tree is being iterated by another process.

大部分 FrameworkContentElement 衍生的類別會公開負責內含專案的專用集合(例如,在 Span 類別上 InlinesBlocksSection 類別上)。Most FrameworkContentElement derived classes expose dedicated collections that are responsible for containment (for example, Inlines on the Span class; Blocks on the Section class). 如果您改為衍生自這些類別,通常可以避免任何需要直接操作邏輯樹狀結構。You can typically avoid any need to manipulate the logical tree directly if you derive from these classes instead. 使用內容專案的邏輯樹狀結構是一種很先進的案例,可能需要專門的剖析器或專門的 FrameworkElement 做為上層轉譯元素(內容主機)。Working with the logical tree for content elements is an advanced scenario that may require a specialized parser or a specialized FrameworkElement that acts as the parent rendering element (content host).

如需如何使用 LogicalChildrenAddLogicalChild的詳細資訊,請參閱WPF 中的樹狀結構。For more information about how to use LogicalChildren and AddLogicalChild, see Trees in WPF.