Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPF Keyboard
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 6-Mar-13 1:48am
Comments
ThePhantomUpvoter at 6-Mar-13 7:31am
   
And your question is what exactly?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

use underscore in text: '_Apple', '_Ball', 'E_xample'
  Permalink  
v2
Comments
kumar.selva.c at 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 at 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 at 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 at 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 at 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?
kumar.selva.c at 7-Mar-13 5:10am
   
@Irina I'm completely blank about this reqiurement. if u have any sample code plz provide.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  

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

  Print Answers RSS
0 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 8 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100