private void search(object _query) { string[] query = Daytimer.Search.Search.StripWhitespace ( Daytimer.Search.Search.RemovePunctuation ( ( (string)_query ).ToLower() ) ) .Trim() .Split(' '); List <Contact> results = new List <Contact>(); if (query.Length > 0 && !string.IsNullOrEmpty(query[0])) { foreach (Contact each in ContactDatabase.GetContacts()) { if (contactMatchesQuery(query, each)) { results.Add(each); } } } if (_cancel) { return; } if (results.Count > 0) { Dispatcher.Invoke(() => { if (_cancel) { return; } statusBar.Text = "RESULTS (" + results.Count.ToString() + ")"; message.Text = ""; contactsListBox.Visibility = Visibility.Visible; contactsListBox.Items.Clear(); foreach (Contact each in results) { contactsListBox.Items.Add(each); } }); } else { Dispatcher.Invoke(() => { if (_cancel) { return; } statusBar.Text = "NO RESULTS"; message.Text = "We couldn't find the person you were looking for. You can try using the more powerful main search (Ctrl+F)."; contactsListBox.Items.Clear(); contactsListBox.Visibility = Visibility.Hidden; }); } }