Exemplo n.º 1
0
 public void OnSelectionChanged(object sender, EventItemChangedArgs e)
 {
     if (OnItemSelectionChanged != null)
     {
         OnItemSelectionChanged(sender, e);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Handles when StyleListBoxItem.Selected is changed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnCollectionItemSelectionChanged(object sender, EventItemChangedArgs e)
        {
            if (e.Item.Selected)
            {
                if (SelectionMode == SelectionMode.One)
                {
                    ClearSelected();
                }

                // from False -> True
                itemSelectedList.Add(e.Item);
                _selectedIndex = e.Item.Index;
                _focusedIndex  = e.Item.Index;
            }
            else
            {
                // from True -> False
                itemSelectedList.Remove(e.Item);

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

            if (SelectedIndexChanged != null)
            {
                SelectedIndexChanged(this, new EventArgs());
            }
        }
Exemplo n.º 3
0
        public void OnCollectionItemChanged(object sender, EventItemChangedArgs e)
        {
            int height = e.Item.MeasureItem();
            int change = height - itemCacheHeight[e.Item.Index];

            itemTotalHeight += change;
            itemCacheHeight[e.Item.Index] = height;

            // Update last visible item index
            if (e.Item.Index < itemFirstVisibleIndex)
            {
                itemFirstVisibleY += change;
                UpdateItemVisibilityByChange(change);
                itemLastVisibleIndex = GetLastVisibleItemIndex();
            }
            else if (e.Item.Index < itemLastVisibleIndex)
            {
                itemLastVisibleIndex = GetLastVisibleItemIndex();
            }

            Update();
        }