First, a fair warning: I'm a complete newbie with C # and WPF.
I have a combobox (editable, searchable) and I would like to be able to grab the Delete key and remove the currently selected item from the list. The behavior I'm looking for is similar to the behavior of MS Outlook when entering email addresses. When you give a few characters, a drop-down list of potential matches is displayed. If you go to one of them (using the arrow keys) and click "Delete", this entry will be permanently deleted. I want to do this with an entry in the combo box.
Here is the XAML (simplified):
<ComboBox x:Name="Directory"
KeyUp="Directory_KeyUp"
IsTextSearchEnabled="True"
IsEditable="True"
Text="{Binding Path=CurrentDirectory, Mode=TwoWay}"
ItemsSource="{Binding Source={x:Static self:Properties.Settings.Default},
Path=DirectoryList, Mode=TwoWay}" />
Handler:
private void Directory_KeyUp(object sender, KeyEventArgs e)
{
ComboBox box = sender as ComboBox;
if (box.IsDropDownOpen && (e.Key == Key.Delete))
{
TrimCombobox("DirectoryList", box.HighlightedItem);
}
}
, box.HighlightedItem , , , :
System.Windows.Controls.ComboBox' does not contain a definition for 'HighlightedItem'...
: ? , . .
.
, . "", , + char, :
alt text http://www.freeimagehosting.net/uploads/2cff35d340.gif