// Token: 0x06004E0F RID: 19983 RVA: 0x0015FE30 File Offset: 0x0015E030 internal void ClearItemContainer(object item, ItemsControl parentItemsControl) { if (this.Generator == null) { return; } if (parentItemsControl != null && VirtualizingPanel.GetIsVirtualizingWhenGrouping(parentItemsControl)) { Helper.StoreItemValues(parentItemsControl, this, item); if (this._expander != null) { Helper.StoreItemValues(parentItemsControl, this._expander, item); } VirtualizingPanel virtualizingPanel = this._itemsHost as VirtualizingPanel; if (virtualizingPanel != null) { virtualizingPanel.OnClearChildrenInternal(); } this.Generator.RemoveAllInternal(true); } else { this.Generator.Release(); } base.ClearContentControl(item); }
//------------------------------------------------------ // // Private Methods // //------------------------------------------------------ // initialize (called during measure, from ApplyTemplate) void AttachToOwner() { DependencyObject templatedParent = this.TemplatedParent; ItemsControl owner = templatedParent as ItemsControl; ItemContainerGenerator generator; if (owner != null) { // top-level presenter - get information from ItemsControl generator = owner.ItemContainerGenerator; } else { // subgroup presenter - get information from GroupItem GroupItem parentGI = templatedParent as GroupItem; ItemsPresenter parentIP = FromGroupItem(parentGI); if (parentIP != null) { owner = parentIP.Owner; } generator = (parentGI != null) ? parentGI.Generator : null; } _owner = owner; UseGenerator(generator); // create the panel, based either on ItemsControl.ItemsPanel or GroupStyle.Panel ItemsPanelTemplate template = null; GroupStyle groupStyle = (_generator != null) ? _generator.GroupStyle : null; if (groupStyle != null) { // If GroupStyle.Panel is set then we dont honor ItemsControl.IsVirtualizing template = groupStyle.Panel; if (template == null) { // create default Panels if (VirtualizingPanel.GetIsVirtualizingWhenGrouping(owner)) { template = GroupStyle.DefaultVirtualizingStackPanel; } else { template = GroupStyle.DefaultStackPanel; } } } else { // Its a leaf-level ItemsPresenter, therefore pick ItemsControl.ItemsPanel template = (_owner != null) ? _owner.ItemsPanel : null; } Template = template; }
internal void ClearItemContainer(object item, ItemsControl parentItemsControl) { if (Generator == null) { return; // user-declared GroupItem - ignore (bug 108423) } ItemContainerGenerator generator = Generator.Parent; GroupStyle groupStyle = generator.GroupStyle; if (Object.Equals(this.Content, item)) { ClearValue(ContentProperty); } if (this.ContentTemplate == groupStyle.HeaderTemplate) { ClearValue(ContentTemplateProperty); } if (this.ContentTemplateSelector == groupStyle.HeaderTemplateSelector) { ClearValue(ContentTemplateSelectorProperty); } if (this.ContentStringFormat == groupStyle.HeaderStringFormat) { ClearValue(ContentStringFormatProperty); } // // ItemValueStorage: save off values for this container if we're a virtualizing Group. // if (parentItemsControl != null && VirtualizingPanel.GetIsVirtualizingWhenGrouping(parentItemsControl)) { Helper.StoreItemValues((IContainItemStorage)parentItemsControl, this, item); if (_expander != null) { Helper.StoreItemValues((IContainItemStorage)parentItemsControl, _expander, item); } // Tell the panel to clear off all its containers. This will cause this method to be called // recursively down the tree, allowing all descendent data to be stored before we save off // the ItemValueStorage DP for this container. VirtualizingPanel vp = _itemsHost as VirtualizingPanel; if (vp != null) { vp.OnClearChildrenInternal(); } Generator.RemoveAllInternal(true /*saveRecycleQueue*/); } else { Generator.Release(); } }
/// <summary>Builds the visual tree for the <see cref="T:System.Windows.Controls.GroupItem" /> when a new template is applied. </summary> // Token: 0x06004E07 RID: 19975 RVA: 0x0015FB34 File Offset: 0x0015DD34 public override void OnApplyTemplate() { base.OnApplyTemplate(); this._header = (base.GetTemplateChild("PART_Header") as FrameworkElement); this._expander = Helper.FindTemplatedDescendant<Expander>(this, this); if (this._expander != null) { ItemsControl parentItemsControl = this.ParentItemsControl; if (parentItemsControl != null && VirtualizingPanel.GetIsVirtualizingWhenGrouping(parentItemsControl)) { Helper.SetItemValuesOnContainer(parentItemsControl, this._expander, parentItemsControl.ItemContainerGenerator.ItemFromContainer(this)); } this._expander.Expanded += GroupItem.OnExpanded; } }
// Token: 0x0600510F RID: 20751 RVA: 0x0016BAE4 File Offset: 0x00169CE4 private void AttachToOwner() { DependencyObject templatedParent = base.TemplatedParent; ItemsControl itemsControl = templatedParent as ItemsControl; ItemContainerGenerator generator; if (itemsControl != null) { generator = itemsControl.ItemContainerGenerator; } else { GroupItem groupItem = templatedParent as GroupItem; ItemsPresenter itemsPresenter = ItemsPresenter.FromGroupItem(groupItem); if (itemsPresenter != null) { itemsControl = itemsPresenter.Owner; } generator = ((groupItem != null) ? groupItem.Generator : null); } this._owner = itemsControl; this.UseGenerator(generator); GroupStyle groupStyle = (this._generator != null) ? this._generator.GroupStyle : null; ItemsPanelTemplate itemsPanelTemplate; if (groupStyle != null) { itemsPanelTemplate = groupStyle.Panel; if (itemsPanelTemplate == null) { if (VirtualizingPanel.GetIsVirtualizingWhenGrouping(itemsControl)) { itemsPanelTemplate = GroupStyle.DefaultVirtualizingStackPanel; } else { itemsPanelTemplate = GroupStyle.DefaultStackPanel; } } } else { itemsPanelTemplate = ((this._owner != null) ? this._owner.ItemsPanel : null); } this.Template = itemsPanelTemplate; }
internal void ClearItemContainer(object item, ItemsControl parentItemsControl) { if (Generator == null) { return; // user-declared GroupItem - ignore ( } // // ItemValueStorage: save off values for this container if we're a virtualizing Group. // if (parentItemsControl != null && VirtualizingPanel.GetIsVirtualizingWhenGrouping(parentItemsControl)) { Helper.StoreItemValues((IContainItemStorage)parentItemsControl, this, item); if (_expander != null) { Helper.StoreItemValues((IContainItemStorage)parentItemsControl, _expander, item); } // Tell the panel to clear off all its containers. This will cause this method to be called // recursively down the tree, allowing all descendent data to be stored before we save off // the ItemValueStorage DP for this container. VirtualizingPanel vp = _itemsHost as VirtualizingPanel; if (vp != null) { vp.OnClearChildrenInternal(); } Generator.RemoveAllInternal(true /*saveRecycleQueue*/); } else { Generator.Release(); } ClearContentControl(item); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); _header = this.GetTemplateChild("PART_Header") as FrameworkElement; // GroupItem is generally re-templated to have an Expander. // Look for an Expander and store its Header size.g _expander = Helper.FindTemplatedDescendant <Expander>(this, this); // // ItemValueStorage: restore saved values for this item onto the new container // if (_expander != null) { ItemsControl itemsControl = ParentItemsControl; if (itemsControl != null && VirtualizingPanel.GetIsVirtualizingWhenGrouping(itemsControl)) { Helper.SetItemValuesOnContainer(itemsControl, _expander, itemsControl.ItemContainerGenerator.ItemFromContainer(this)); } _expander.Expanded += new RoutedEventHandler(OnExpanded); } }
// Token: 0x06004E0E RID: 19982 RVA: 0x0015FCB8 File Offset: 0x0015DEB8 internal void PrepareItemContainer(object item, ItemsControl parentItemsControl) { if (this.Generator == null) { return; } if (this._itemsHost != null) { this._itemsHost.IsItemsHost = true; } bool flag = parentItemsControl != null && VirtualizingPanel.GetIsVirtualizingWhenGrouping(parentItemsControl); if (this.Generator != null) { if (!flag) { this.Generator.Release(); } else { this.Generator.RemoveAllInternal(true); } } ItemContainerGenerator parent = this.Generator.Parent; GroupStyle groupStyle = parent.GroupStyle; Style style = groupStyle.ContainerStyle; if (style == null && groupStyle.ContainerStyleSelector != null) { style = groupStyle.ContainerStyleSelector.SelectStyle(item, this); } if (style != null) { if (!style.TargetType.IsInstanceOfType(this)) { throw new InvalidOperationException(SR.Get("StyleForWrongType", new object[] { style.TargetType.Name, base.GetType().Name })); } base.Style = style; base.WriteInternalFlag2(InternalFlags2.IsStyleSetFromGenerator, true); } if (base.ContentIsItem || !base.HasNonDefaultValue(ContentControl.ContentProperty)) { base.Content = item; base.ContentIsItem = true; } if (!base.HasNonDefaultValue(ContentControl.ContentTemplateProperty)) { base.ContentTemplate = groupStyle.HeaderTemplate; } if (!base.HasNonDefaultValue(ContentControl.ContentTemplateSelectorProperty)) { base.ContentTemplateSelector = groupStyle.HeaderTemplateSelector; } if (!base.HasNonDefaultValue(ContentControl.ContentStringFormatProperty)) { base.ContentStringFormat = groupStyle.HeaderStringFormat; } Helper.ClearVirtualizingElement(this); if (flag) { Helper.SetItemValuesOnContainer(parentItemsControl, this, item); if (this._expander != null) { Helper.SetItemValuesOnContainer(parentItemsControl, this._expander, item); } } }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ internal void PrepareItemContainer(object item, ItemsControl parentItemsControl) { if (Generator == null) { return; // user-declared GroupItem - ignore ( } // If a GroupItem is being recycled set back IsItemsHost if (_itemsHost != null) { _itemsHost.IsItemsHost = true; } bool isVirtualizingWhenGrouping = (parentItemsControl != null && VirtualizingPanel.GetIsVirtualizingWhenGrouping(parentItemsControl)); // Release any previous containers. Also ensures Items and GroupStyle are hooked up correctly if (Generator != null) { if (!isVirtualizingWhenGrouping) { Generator.Release(); } else { Generator.RemoveAllInternal(true /*saveRecycleQueue*/); } } ItemContainerGenerator generator = Generator.Parent; GroupStyle groupStyle = generator.GroupStyle; // apply the container style Style style = groupStyle.ContainerStyle; // no ContainerStyle set, try ContainerStyleSelector if (style == null) { if (groupStyle.ContainerStyleSelector != null) { style = groupStyle.ContainerStyleSelector.SelectStyle(item, this); } } // apply the style, if found if (style != null) { // verify style is appropriate before applying it if (!style.TargetType.IsInstanceOfType(this)) { throw new InvalidOperationException(SR.Get(SRID.StyleForWrongType, style.TargetType.Name, this.GetType().Name)); } this.Style = style; this.WriteInternalFlag2(InternalFlags2.IsStyleSetFromGenerator, true); } // forward the header template information if (ContentIsItem || !HasNonDefaultValue(ContentProperty)) { this.Content = item; ContentIsItem = true; } if (!HasNonDefaultValue(ContentTemplateProperty)) { this.ContentTemplate = groupStyle.HeaderTemplate; } if (!HasNonDefaultValue(ContentTemplateSelectorProperty)) { this.ContentTemplateSelector = groupStyle.HeaderTemplateSelector; } if (!HasNonDefaultValue(ContentStringFormatProperty)) { this.ContentStringFormat = groupStyle.HeaderStringFormat; } // // Clear previously cached items sizes // Helper.ClearVirtualizingElement(this); // // ItemValueStorage: restore saved values for this item onto the new container // if (isVirtualizingWhenGrouping) { Helper.SetItemValuesOnContainer(parentItemsControl, this, item); if (_expander != null) { Helper.SetItemValuesOnContainer(parentItemsControl, _expander, item); } } }