예제 #1
0
        /// <summary>
        /// Updates the selected items list by adding or removing the <see cref="SelectableItem{T}"/>.
        /// </summary>
        /// <param name="item">A <see cref="SelectableItem{T}"/> that will be added or removed from the selected
        /// items list.</param>
        private void UpdateSelectedItemsList(SelectableItem <T> item)
        {
            var idx = this.IndexOf(item);

            if (!item.IsSelected)
            {
                if (this.MaintainsSelectedItemsOrder)
                {
                    _selectedItemsIndexes.Remove(idx);
                }

                _selectedItems.Remove(item.Item);
            }
            else
            {
                if (this.MaintainsSelectedItemsOrder)
                {
                    if (_selectedItemsIndexes.Count == 0 || _selectedItemsIndexes[_selectedItemsIndexes.Count - 1] < idx)
                    {
                        _selectedItemsIndexes.Add(idx);
                        _selectedItems.Add(item.Item);
                    }
                    else if (_selectedItemsIndexes[0] > idx)
                    {
                        _selectedItemsIndexes.Insert(0, idx);
                        _selectedItems.Insert(0, item.Item);
                    }
                    else
                    {
                        int indexOfNextGreatest = _selectedItemsIndexes.IndexOf(_selectedItemsIndexes.Where(i => i > idx).First());

                        _selectedItemsIndexes.Insert(indexOfNextGreatest, idx);
                        _selectedItems.Insert(indexOfNextGreatest, item.Item);
                    }
                }
                else
                {
                    _selectedItems.Add(item.Item);
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SelectableItemChangedEventArgs{T}" /> class.
 /// </summary>
 /// <param name="changedItem">The changed item.</param>
 public SelectableItemChangedEventArgs(SelectableItem <T> changedItem)
 {
     this.ChangedItem = changedItem;
 }
예제 #3
0
        private void BindToSelectableItem(SelectableItem <T> item)
        {
            item.PropertyChanged += this.OnItemPropertyChanged;

            this.UpdateSelectedItemsList(item);
        }