private void TextBoxSearchPresetsKeyUp(object sender, KeyEventArgs e) { try { if (e.Key == Key.Escape) { _mainWindowLocalization.TreeViewSearchText = string.Empty; TextBoxSearchPresets.UpdateLayout(); } if (_mainWindowLocalization.TreeViewSearchText.Length == 0) { _treeViewSearch.Reset(); treeViewPresets.SetTreeViewState(_treeViewState); } else { _treeViewSearch.Search(_mainWindowLocalization.TreeViewSearchText); } } catch (Exception ex) { MessageBox.Show("Failed to execute search successfully."); App.WriteToErrorLog("Failed to execute search successfully", ex.Message, ex.StackTrace); } }
private void TextBoxSearchPresetsKeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Escape) { //used to fix issue with misplaced caret in TextBox TextBoxSearchPresets.UpdateLayout(); TextBoxSearchPresets.Dispatcher.Invoke(DispatcherPriority.Render, new Action(() => { })); //TextBoxSearchPresets.InvalidateVisual(); } }