internal virtual void GenerateChildren() { // This method is typically called during layout, which suspends the dispatcher. // Firing an assert causes an exception "Dispatcher processing has been suspended, but messages are still being processed." // Besides, the asserted condition can actually arise in practice, and the // code responds harmlessly. //Debug.Assert(_itemContainerGenerator != null, "Encountered a null _itemContainerGenerator while being asked to generate children."); IItemContainerGenerator generator = (IItemContainerGenerator)_itemContainerGenerator; if (generator != null) { using (generator.StartAt(new GeneratorPosition(-1, 0), GeneratorDirection.Forward)) { UIElement child; while ((child = generator.GenerateNext() as UIElement) != null) { _uiElementCollection.AddInternal(child); generator.PrepareItemContainer(child); } } } }
// This is internal as an optimization for VirtualizingStackPanel (so it doesn't need to re-query InternalChildren repeatedly) internal static void AddInternalChild(UIElementCollection children, UIElement child) { children.AddInternal(child); }