private void searchTextBox_KeyDown(object sender, KeyEventArgs e)
{
var textBox = sender as SearchTextBox;
if (e.Key == Key.Enter && listBox.Items.Count > 0)
{
if ((textBox != null && textBox.Text != "") ||
(listBox.SelectedIndex > -1 && listBox.SelectedIndex < listBox.Items.Count + 1)
)
CreateNode();
else
{
Hide();
}
}
else
{
switch (e.Key)
{
case Key.Down:
if (listBox.SelectedIndex < listBox.Items.Count)
{
listBox.SelectedIndex += 1;
e.Handled = true;
}
break;
case Key.Up:
if (listBox.SelectedIndex > 0) listBox.SelectedIndex -= 1;
e.Handled = true;
break;
}
}
}