Esempio n. 1
0
        public void PerformSearch(string searchString)
        {
            var lCaseSearch = searchString.ToLower();

            var result = _searchList.FindAll(item => item.ToLower().Contains(lCaseSearch));

            if (result.Count == 0)
            {
                return;
            }

            _searchResults.Clear();
            foreach (var s in result)
            {
                _searchResults.Add(s);
            }

            ListCommandSearch.Items.Refresh();
            if (_searchResults.Count > 0)
            {
                ListCommandSearch.SelectedIndex = 0;
            }

            TextSearchBox.Text            = searchString;
            TextSearchBox.SelectionStart  = 0;
            TextSearchBox.SelectionLength = searchString.Length;
            TextSearchBox.Focus();
        }
Esempio n. 2
0
        public SearchDialog(List <string> searchList, string defaultSearch = "", bool showNoSelection = true)
        {
            InitializeComponent();

            ButtonClearSlot.Visibility = showNoSelection ? Visibility.Visible : Visibility.Collapsed;

            _searchList = searchList;

            ListCommandSearch.ItemsSource = _searchResults;

            if (defaultSearch != "")
            {
                PerformSearch(defaultSearch);
            }

            _lastSearch = int.MaxValue.ToString();

            TextSearchBox.Focus();
        }