Hi How do i select the checkbox using keyboard.
Regards,
Rajiv
Hello Rajiv,
This has to do with how the combo editor handles focus. Let's say I have 4 items in the drop down, and I select item 3 and 4. If I place focus on the 3rd item and press the space bar, it sets the IsSelected of this item to false because it currently has focus. Once the item is deselected, the editor internally moves focus to the next selected item. This item is the 4th one. Now the for loop executes again but because the 4th item is now focused, it executes the selection code again which deselects it. In order to stop this you'll have to stick a break after the e.Handled = true.
Hi Rob,
I am using shared combo editor, I have used the same code for selection, and written some code for deselection of item with space. Selecting is working fine, where as deselection isn't, it deselectes 2-3 values.
Here is my code snippet
if (e.Key == Key.Space) { XamComboEditor xamCombo = (XamComboEditor)sender; foreach (ComboEditorItem item in xamCombo.Items) { if (item.IsFocused) { if (item.IsSelected) { item.IsSelected = false; e.Handled = true; } else { item.IsSelected = true; e.Handled = true; } } } }
Can you check.
rajiv
Hi Rajiv,
Since you did not specify which XamComboEditor you are using, I attached a sample that demonstrates how to implement space bar selection for both the WPF only XamComboEditor and the shared version.
The sample handles the PreviewKeyDown event on both the editors and it detects when an item is highlighted and the space bar is pressed so that it can select it.
Let me know if you have any questions on this.