Ejemplo n.º 1
0
        public void OnCollectionItemAdded(object sender, EventItemArgs e)
        {
            int height          = e.Item.MeasureItem();
            int lastTotalHeight = itemTotalHeight;

            itemTotalHeight += height;
            itemCacheHeight.Add(height);

            // Update last visible item index
            if (scroll.Value + this.Height > lastTotalHeight)
            {
                itemLastVisibleIndex = GetLastVisibleItemIndex();
            }

            Update();
        }
Ejemplo n.º 2
0
        public void OnCollectionItemRemoved(object sender, EventItemArgs e)
        {
            int height = e.Item.MeasureItem();

            itemTotalHeight -= height;
            itemCacheHeight.RemoveAt(e.Item.Index);

            if (e.Item.Selected)
            {
                itemSelectedList.Remove(e.Item);

                if (_selectedIndex == e.Item.Index)
                {
                    if (itemSelectedList.Count > 0)
                    {
                        _selectedIndex = itemSelectedList[0].Index;
                    }
                    else
                    {
                        _selectedIndex = -1;
                    }
                }
            }

            // Update first visible item index and last visible item index accordingly
            if (e.Item.Index <= itemFirstVisibleIndex)
            {
                UpdateItemVisibilityByChange(-height);
                itemLastVisibleIndex = GetLastVisibleItemIndex();
            }
            else if (e.Item.Index <= itemLastVisibleIndex)
            {
                itemLastVisibleIndex = GetLastVisibleItemIndex();
            }

            Update();
        }