private void ReloadViewModel() { Debug.Assert(_context != null, "ExplorerFrame was disposed"); // if _viewModelHelper doesn't exist then create and subscribe to ViewModelChanged event if (_viewModelHelper == null) { _viewModelHelper = GetNewExplorerViewModelHelper(); _viewModelHelper.ExplorerViewModelChanged += OnViewModelChange; } // create a new ViewModel and assign it to the ViewModelHelper - this // will cause ViewModelChanged event to be fired and we will update // the DataContext in OnViewModelChange() below _viewModelHelper.CreateViewModel(_context); }
// Invoked when the user clicks the Search Go Button private void OnSearchCommand() { var previousCursor = _frameContent.Cursor; try { _frameContent.Cursor = Cursors.AppStarting; SearchComboBox.IsHitTestVisible = false; _frameContent.UpdateLayout(); var searchCriteria = SearchComboBox.Text.Trim(); if (string.IsNullOrEmpty(searchCriteria)) { // textbox could have whitespace in it - if so do not search but need to set // textbox text back to empty to re-enable search button SearchComboBox.Text = string.Empty; // Note: without below search combo box is not enabled after first call SearchComboBox.IsHitTestVisible = true; } else { // Do the actual search and put the results into a SearchResults (which is an editing context item) var searchResults = ExplorerViewModelHelper.SearchModelByDisplayName(searchCriteria); if (!SearchComboBox.Items.Contains(searchCriteria)) { SearchComboBox.Items.Insert(0, searchCriteria); } DisplaySearchResults(searchResults, false); } } finally { _frameContent.Cursor = previousCursor; } }