/// <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); }