When the user starts typing in a combobox, auto-complete kicks in and shows the closest match. What I want to do is have the drop-down become visible as well, as if the user clicked the down arrow. Can this be done and if yes, how?
A:
You could hook the KeyDown
event on the ComboBox
, and then set the IsDropDownOpen
property to true.
in XAML:
<ComboBox x:Name="MyComboBox"
IsEditable="True"
IsReadOnly="False"
KeyDown="MyComboBox_KeyDown"/>
in code behind:
private void MyComboBox_KeyDown(object sender, KeyEventArgs e) {
if (MyComboBox.Text.Length > 0)
MyComboBox.IsDropDownOpen = true;
}
Henry Jackson
2010-03-30 18:56:55
PreviewKeyDown would be a better place. Opening the drop down resets the text position in the textbox.
Scott J
2010-03-30 19:05:12
Thanks! This worked. I was hoping there was some cool way to do it in the XAML, but this works.
John Michaels
2010-03-30 19:07:32