// // Public functionality // public void FocusFirstField() { if (ComboBoxToolsFindText == null) { return; } ComboBoxToolsFindText.Focus(); }
// // Initialize // public ToolControlFindReplace() { InitializeComponent(); TheSearchOptions.allowedAssemblies = new[] { typeof(AdminShell).Assembly }; // the combo box needs a special treatment in order to have it focussed .. ComboBoxToolsFindText.Loaded += (object sender, RoutedEventArgs e) => { // try focus again after loading .. ComboBoxToolsFindText.Focus(); }; ComboBoxToolsFindText.GotFocus += (object sender, RoutedEventArgs e) => { var textBox = ComboBoxToolsFindText.Template.FindName( "PART_EditableTextBox", ComboBoxToolsFindText) as TextBox; if (textBox != null) { textBox.Select(0, textBox.Text.Length); } }; }