I understand that even the NonEditable RadComboBox will take keyboard input to navigate to values that match the letters typed, but the functionality of the RadComboBox is lacking compared to traditional pull-down menus both on the web and within operating systems.
May I suggest the following feature request, modeled after typical Microsoft Windows pull-down menus:
And here's how it's handled within web browsers:
That's pretty much it. Obviously, the 1st Windows-based functionality is the most powerful, but the 2nd web-based functionality is a step forward from the way the RadComboBox works right now, unless I'm totally overlooking something.
Here's a basic rundown of the logic:
I'm sure you guys will do a much better job with the logic on your end, but this is the general idea of where I was going with this. I still can't get it to work with the code above, but I can't really override some of the functions I want to to make it work, like the RadComboBoxKeyDown event or the textInput variable.
May I suggest the following feature request, modeled after typical Microsoft Windows pull-down menus:
- The text input should be reset the moment a keystroke is entered that returns no matches.
- Backspace input is no longer required for the NonEditable RadComboBox, based on the above request. Of course, you will want to keep backspace input for the Editable RadComboBox.
And here's how it's handled within web browsers:
- Text input is reset after 1 second of no keystrokes.
That's pretty much it. Obviously, the 1st Windows-based functionality is the most powerful, but the 2nd web-based functionality is a step forward from the way the RadComboBox works right now, unless I'm totally overlooking something.
Here's a basic rundown of the logic:
using System.Text.RegularExpressions; |
private string userInput; |
private Regex alphaNumeric; |
public ESOComboBox() |
{ |
InitializeComponent(); |
alphaNumeric = new Regex("[\\w\\s]+", RegexOptions.IgnoreCase); // Alphanumeric, underscores and spaces |
} |
private bool SelectMatchedComboItem(RadComboBox combo) |
{ |
foreach (RadComboBoxItem item in combo.Items) |
{ |
if (item.Content.ToString().StartsWith(userInput)) |
{ |
combo.SelectedItem = item; |
return true; |
} |
} |
return false; |
} |
private void ESOComboBox_GotFocus(object sender, RoutedEventArgs e) |
{ |
userInput = null; |
} |
private void ESOComboBoxKeyDown(object sender, KeyEventArgs e) |
{ |
switch (e.Key) |
{ |
case Key.Back: |
case Key.Enter: |
case Key.Escape: |
case Key.PageUp: |
case Key.PageDown: |
case Key.End: |
case Key.Home: |
case Key.Left: |
case Key.Up: |
case Key.Right: |
case Key.Down: |
break; |
default: |
char ch = Convert.ToChar(e.PlatformKeyCode); |
if (alphaNumeric.IsMatch(ch.ToString())) |
{ |
userInput += ch; |
RadComboBox combo = sender as RadComboBox; |
if (!SelectMatchedComboItem(combo)) |
{ |
userInput = ch.ToString(); |
SelectMatchedComboItem(combo); |
} |
} |
e.Handled = true; |
break; |
} |
} |
I'm sure you guys will do a much better job with the logic on your end, but this is the general idea of where I was going with this. I still can't get it to work with the code above, but I can't really override some of the functions I want to to make it work, like the RadComboBoxKeyDown event or the textInput variable.
- The latest version of Silverlight 2 is installed, version Silverlight 2 GDR 1 (2.0.40115.0).
- Operating System: Windows Vista Home Premium (32-bit).
- Attempted Browsers: Internet Explorer 8.0.6001.18702, Mozilla Firefox version 3.0.10, Google Chrome 2.0.172.28.
- Telerik version: 2009.1.413.1020.
- Preferred programming language: C#.
- Microsoft Visual Studio 2008 Professional Edition, Version 9.0.30729.1 SP.
- Microsoft Expression Blend 2 Service Pack 1, Version 2.1.1760.0.