public void DeepCopy(IDeepCopyable source, ICopyManager copyManager) { ListViewItemGenerator icg = (ListViewItemGenerator)source; _itemTemplate = copyManager.GetCopy(icg._itemTemplate); _itemContainerStyle = copyManager.GetCopy(icg._itemContainerStyle); _groupingValueProvider = icg._groupingValueProvider; _groupPropertyBinding = copyManager.GetCopy(icg._groupPropertyBinding); _groupHeaderTemplate = copyManager.GetCopy(icg._groupHeaderTemplate); _groupHeaderContainerStyle = copyManager.GetCopy(icg._groupHeaderContainerStyle); _parent = copyManager.GetCopy(icg._parent); if (icg._items == null) { _items = null; } else { _items = new List <object>(icg._items.Count); foreach (object item in icg._items) { _items.Add(copyManager.GetCopy(item)); } } _populatedStartIndex = icg._populatedStartIndex; _populatedEndIndex = icg._populatedEndIndex; if (icg._materializedItems == null) { _materializedItems = null; } else { _materializedItems = new List <FrameworkElement>(icg._materializedItems.Count); foreach (FrameworkElement item in icg._materializedItems) { _materializedItems.Add(copyManager.GetCopy(item)); } } if (icg._materializedGroupHeaders == null) { _materializedGroupHeaders = null; } else { _materializedGroupHeaders = new HeaderItemWrapper[icg._materializedGroupHeaders.Length]; for (int n = 0; n < icg._materializedGroupHeaders.Length; ++n) { _materializedGroupHeaders[n] = copyManager.GetCopy(icg._materializedGroupHeaders[n]); } } }
public void Dispose() { DisposeItems(); MPF.TryCleanupAndDispose(_itemTemplate); _itemTemplate = null; MPF.TryCleanupAndDispose(_itemContainerStyle); _itemContainerStyle = null; _groupingValueProvider = null; MPF.TryCleanupAndDispose(_groupPropertyBinding); _groupPropertyBinding = null; MPF.TryCleanupAndDispose(_groupHeaderTemplate); _groupHeaderTemplate = null; MPF.TryCleanupAndDispose(_groupHeaderContainerStyle); _groupHeaderContainerStyle = null; MPF.TryCleanupAndDispose(_getValueGroupHeader); _getValueGroupHeader = null; }
public void Initialize(FrameworkElement parent, IEnumerable <object> itemsSource, Style itemContainerStyle, DataTemplate itemTemplate, IGroupingValueProvider groupingValueProvider, IBinding groupPropertyBinding, Style groupHeaderContainerStyle, DataTemplate groupHeaderTemplate) { _parent = parent; DisposeItems(); _items = new List <object>(itemsSource); _materializedItems = new List <FrameworkElement>(_items.Count); for (int i = 0; i < _items.Count; i++) { _materializedItems.Add(null); } _groupInfos = null; if ((groupingValueProvider != null && groupingValueProvider.IsGroupingActive) || groupPropertyBinding != null) { _materializedGroupHeaders = new HeaderItemWrapper[_items.Count]; } MPF.TryCleanupAndDispose(_itemContainerStyle); MPF.TryCleanupAndDispose(_itemTemplate); // No need to set the LogicalParent at styles or data templates because they don't bind bindings _itemContainerStyle = MpfCopyManager.DeepCopyCutLVPs(itemContainerStyle); _itemTemplate = MpfCopyManager.DeepCopyCutLVPs(itemTemplate); MPF.TryCleanupAndDispose(_groupHeaderContainerStyle); MPF.TryCleanupAndDispose(_groupHeaderTemplate); MPF.TryCleanupAndDispose(_groupPropertyBinding); _groupingValueProvider = groupingValueProvider; _groupPropertyBinding = MpfCopyManager.DeepCopyCutLVPs(groupPropertyBinding); _groupHeaderContainerStyle = MpfCopyManager.DeepCopyCutLVPs(groupHeaderContainerStyle); _groupHeaderTemplate = MpfCopyManager.DeepCopyCutLVPs(groupHeaderTemplate); MPF.TryCleanupAndDispose(_getValueGroupHeader); _getValueGroupHeader = null; }