Exemplo n.º 1
0
        protected override IVirtualizedElement <ListViewDataItem> UpdateElement(int position, ListViewDataItem data)
        {
            IVirtualizedElement <ListViewDataItem> element = null;
            object elementContext = this.GetElementContext();

            if (position < this.Children.Count)
            {
                element = (IVirtualizedElement <ListViewDataItem>) this.Children[position];
                if (ElementProvider.ShouldUpdate(element, data, elementContext))
                {
                    if (position < this.Children.Count - 1)
                    {
                        IVirtualizedElement <ListViewDataItem> nextElement = (IVirtualizedElement <ListViewDataItem>) this.Children[position + 1];

                        if (nextElement.Data.Equals(data))
                        {
                            this.Children.Move(position + 1, position);
                            nextElement.Synchronize();
                            return(nextElement);
                        }
                    }

                    if (ElementProvider.IsCompatible(element, data, elementContext))
                    {
                        element.Detach();
                        element.Attach(data, elementContext);
                    }
                    else
                    {
                        int index = FindCompatibleElement(position, data);
                        if (index > position)
                        {
                            this.Children.Move(index, position);
                            element = (IVirtualizedElement <ListViewDataItem>) this.Children[position];
                            element.Detach();
                            element.Attach(data, elementContext);
                        }
                        else
                        {
                            position = Math.Min(position, this.Children.Count);
                            element  = ElementProvider.GetElement(data, elementContext);
                            InsertElement(position, element, data);
                        }
                    }
                }
            }
            else
            {
                position = Math.Min(position, this.Children.Count);
                element  = ElementProvider.GetElement(data, elementContext);
                InsertElement(position, element, data);
            }

            return(element);
        }
Exemplo n.º 2
0
        protected virtual void RemoveElement(int position)
        {
            IVirtualizedElement <T> virtualizedElement = (IVirtualizedElement <T>) this.Children[position];

            ElementProvider.CacheElement(virtualizedElement);
            this.BitState[InvalidateMeasureOnRemoveStateKey] = false;
            this.Children.RemoveAt(position);
            this.BitState[InvalidateMeasureOnRemoveStateKey] = true;
            virtualizedElement.Detach();
        }
        protected virtual void RemoveElement(int position)
        {
            IVirtualizedElement <T> child = (IVirtualizedElement <T>) this.Children[position];

            this.ElementProvider.CacheElement(child);
            this.InvalidateMeasureOnRemove = false;
            this.Children.RemoveAt(position);
            this.InvalidateMeasureOnRemove = true;
            child.Detach();
        }
        public virtual SizeF MeasureItem(Item item, SizeF availableSize)
        {
            IVirtualizedElement <Item> element = this.ViewElement.ElementProvider.GetElement(item, (object)null);
            RadElement radElement = (RadElement)element;

            this.SuspendLayout();
            this.Children.Add(radElement);
            element.Attach(item, (object)null);
            radElement.ResetLayout(true);
            radElement.Measure(availableSize);
            SizeF desiredSize = radElement.GetDesiredSize(false);

            this.Children.Remove(radElement);
            this.ViewElement.ElementProvider.CacheElement(element);
            element.Detach();
            this.ResumeLayout(false);
            return(desiredSize);
        }