Пример #1
0
        public void ClearItems()
        {
            if (_items.Count == 0)
            {
                return;
            }

            _items.Clear();
            _selection.Clear();
            InvalidateHierarchy();
        }
Пример #2
0
        /// <summary>
        /// Sets the selection to only the passed item, if it is a possible choice.
        /// </summary>
        /// <param name="item">Item.</param>
        public ListBox <T> SetSelected(T item)
        {
            if (_items.Contains(item))
            {
                _selection.Set(item);
            }
            else if (_selection.GetRequired() && _items.Count > 0)
            {
                _selection.Set(_items[0]);
            }
            else
            {
                _selection.Clear();
            }

            return(this);
        }