protected override void OnApplyTemplate() #endif { base.OnApplyTemplate(); // Attempt to find the <ItemsPresenter /> in the ControlTemplate and, if it was found, use it as the place where all the items should be added: ItemsPresenter itemsPresenter = INTERNAL_VisualTreeManager.GetChildOfType <ItemsPresenter>(this); if (itemsPresenter != null) { _placeWhereItemsPanelWillBeRendered = itemsPresenter; } // Update the ItemsPanel: UpdateItemsPanel(ItemsPanel); }
protected override void OnApplyTemplate() #endif { base.OnApplyTemplate(); // Attempt to find the <ItemsPresenter /> in the ControlTemplate and, // if it was found, use it as the place where all the items will be added ItemsPresenter itemsPresenter = this.GetTemplateChild("ItemsHost") as ItemsPresenter; if (itemsPresenter == null) { // Note: In Silverlight and WPF, the ItemsPresenter does not need to be // named ItemsHost. However, the method used below does not work properly // in some cases. For instance, if the ItemsPresenter is the content of a // Popup, it will not be found at this point. (ex: ComboBox default style) itemsPresenter = INTERNAL_VisualTreeManager.GetChildOfType <ItemsPresenter>(this); } if (itemsPresenter != null) { this._itemsPresenter = itemsPresenter; itemsPresenter.AttachToOwner(this); } }