How to display intellisence popup for custom key combinations?
In EditControl, Intellisence Popup can be displayed for user defined Key combinations by handling KeyDown event.
For Example
Here we have displayed the intellisence Popup for Key combination “E”.
The following Code sample demonstrates the same.
C#
//Holds the List box control in Intellisence popup
listbox = (sender as EditControl).Template.FindName("PART_IntellisenseBox", (sender as EditControl)) as ListBox;
//Holds the Intellisence popup
popup = (sender as EditControl).Template.FindName("PART_IntellisensePopup", (sender as EditControl)) as Popup;
/// <summary>
/// KeyDown1 event to check the key pressed
/// </summary>
private void EditSQL_KeyDown1(object sender, KeyEventArgs e)
{
items = new ObservableCollection<CustomIntellisenseItem>();
if (e.Key == Key.E)
{
items = customItems;
popup.Height = 200;
//Set listbox visible
listbox.Visibility = Visibility.Visible;
}
else
{
popup.Height = 0;
//Set listbox as collapsed
listbox.Visibility = Visibility.Collapsed;
}
editSQL.IntellisenseCustomItemsSource = items;
}
VB
'Holds the List box control in Intellisence popup
listbox = TryCast((TryCast(sender, EditControl)).Template.FindName("PART_IntellisenseBox", (TryCast(sender, EditControl))), ListBox)
'Holds the Intellisence popup
popup = TryCast((TryCast(sender, EditControl)).Template.FindName("PART_IntellisensePopup", (TryCast(sender, EditControl))), Popup)
''' <summary>
''' KeyDown1 event to check the key pressed
''' </summary>
Private Sub EditSQL_KeyDown1(ByVal sender As Object, ByVal e As KeyEventArgs)
items = New ObservableCollection(Of CustomIntellisenseItem)()
If e.Key = Key.E Then
items = customItems
popup.Height = 200
'Set listbox visible
listbox.Visibility = Visibility.Visible
Else
popup.Height = 0
'Set listbox as collapsed
listbox.Visibility = Visibility.Collapsed
End If
editSQL.IntellisenseCustomItemsSource = items
End Sub
Screenshot

Sample Links