I have how to select SelectAll text when I click on a TextBox; I want to do the same for editable combobox - din find something. My code for TextBox is
private void OnPreviewMouseDown(Object sender, MouseButtonEventArgs e) { txtBox.SelectAll(); txtBox.Focus(); e.Handled = true; }
How can this be done for Editable Combobox?
Update Code for Combox that gives me the output I want:
private void cboMouseDown(object sender, MouseButtonEventArgs e) { var textBox = (cbo.Template.FindName("PART_EditableTextBox", cbo) as TextBox); if (textBox != null) { textBox.SelectAll(); cbo.Focus(); e.Handled = true; } }
But now the combobox doesn't work, any suggestion?
Update-2 : instead of PreviewMouseDown - I tried PreviewMouseUp, and now a popup menu appears; but when he once clicked on the box, and then tried to open the drop-down list, the window freezes. However, I did the work that I put in response. I would really appreciate your comments, though, if this is the right and safe decision I can go with.
source share