Click here to Skip to main content
15,891,852 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have 10 check box items sorted Alphabetically ,say for example ,Apple,AirCraft,Ball,Bottom,Cat etc..by pressing A through keyboard focus must be set to Apple check box,B to Ball . These Checkbox Items are dynamically variable due to Item source count. Thanx in advance.
Posted
Comments
[no name] 6-Mar-13 7:31am    
And your question is what exactly?

use underscore in text: '_Apple', '_Ball', 'E_xample'
 
Share this answer
 
v2
Comments
kumar.selva.c 7-Mar-13 1:28am    
Really thanx a lot, Now i Stuck up another Issue, I did as per ur guidence, Issue is, I'll load My checkBox items through Configuration file which are not sorted, so in code behind ill sort using Icomparer,when i use "_" for Shortcut, the Items are not getting Sorted
Irina Pykhova 7-Mar-13 2:08am    
place text without "_" to some special property and sort by it. For example, for check boxes you can use Tag property.
kumar.selva.c 7-Mar-13 2:37am    
@Irina I did'nt get you, could u plz give me sample with code. so it might be usefull. Thanx in advance. Since Checkbox Items are not HardCoded in XAML i cannot Tag i guess, i load them during run time. and what if i have Items like
1. Apple
2. Apple1
3. Apple2

In this scenario i can't set Shortcut rite, so instead, If i Press "A" first item that starts with letter "A" will get Focus and again Pressing "A" Focus set to next Item that starts with letter "A", if it reaches the last item starts with letter "A" then again if i press "A" it has to goto the first item that has starting letter "A". so this is my requirement:). could u plz help me out this.
Moreover thanx for ur quick reply.
Irina Pykhova 7-Mar-13 5:07am    
I'm afraid that it can't be done with standard keyboard shortcuts. Looks like you should handle KeyDown event and in the event handler set focus to the next element.
kumar.selva.c 8-Mar-13 6:13am    
@Irina.. I can achive this by using Listview, but if i use it inside Datatemplate then im unable to use that previlage. Do u have any idea?
Thanx for all, I have found answer to this question by myself, its ver very simple to traverse Items ,

By pressing the <kbd>A</kbd> key the focus must be set to the **Apple** check box, <kbd>B</kbd> - to **Ball**. These check box items are dynamically variable due to item source count.

Jus do it as below, place underscore symbol "_" before "A"
1. _Apple
2. _Apple1
3. _Apple2


If i Press <kbd>A</kbd> first item that starts with letter A will get Focus and again Pressing <kbd>A</kbd> Focus set to next Item that starts with letter A, if it reaches the last item starts with letter A then again if i press <kbd>A</kbd> it will goto the first item that has starting letter A. If u want to check the checkbox u can use <kbd>SpaceBar</kbd>, provided checkbox items must be withtin ItemsControl.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900