private void PerformSearch(DatabaseItemViewModel model) { if (_searchEnumerator != null && _searchEnumerator.MoveNext()) { return; } if (_searchEnumerator == null || !_searchEnumerator.MoveNext()) { VerifySearchEnumerator(model); } var currentObject = _searchEnumerator?.Current; if (currentObject == null) { return; } // Ensure that this person is in view. if (currentObject.Parent != null) { currentObject.Parent.IsExpanded = true; } currentObject.IsHighlighted = true; }
private void VerifySearchEnumerator(DatabaseItemViewModel model) { TreeViewItemViewModel firstAvailable = model; if (firstAvailable != null) { var matches = FindMatches(SearchText, firstAvailable); _searchEnumerator = matches.GetEnumerator(); } if (!_searchEnumerator.MoveNext()) { MessageBox.Show( "No matching names were found.", "Try Again", MessageBoxButton.OK, MessageBoxImage.Information ); } }