public void DeepCopy(IDeepCopyable source, ICopyManager copyManager)
 {
   ListViewItemGenerator icg = (ListViewItemGenerator) source;
   _itemTemplate = copyManager.GetCopy(icg._itemTemplate);
   _itemContainerStyle = copyManager.GetCopy(icg._itemContainerStyle);
   _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));
   }
 }
    protected IList<FrameworkElement> _materializedItems = null; // Same size as _items, only parts are populated

    public void Dispose()
    {
      DisposeItems();
      MPF.TryCleanupAndDispose(_itemTemplate);
      _itemTemplate = null;
      MPF.TryCleanupAndDispose(_itemContainerStyle);
      _itemContainerStyle = null;
    }
 public void Initialize(FrameworkElement parent, IEnumerable<object> itemsSource, Style itemContainerStyle, DataTemplate itemTemplate)
 {
   _parent = parent;
   if (_materializedItems != null)
     DisposeItems();
   _items = new List<object>(itemsSource);
   _materializedItems = new List<FrameworkElement>(_items.Count);
   for (int i = 0; i < _items.Count; i++)
     _materializedItems.Add(null);
   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);
 }