I think lightswitch community is rocking as expected. Ya, It should basically release of LightSwitch HTML Client Preview 2. Hmmm, Again good work by Microsoft LightSwitch Team. Many Thanks.
I would also like to thank MSDN team, due to selecting me for the MCC award program.
After a long time back, I was busy in my holiday session.
In today's article i am gonna show you on how you can implement custom keyboard shortcut in lightswitch 2012.
Prerequisite: Microsoft Visual Studio 2012 Professional or higher. Not yet tested in LightSwitch 2011.
For my current project there is a huge requirement of keyboard shortcut. So my target is, I have to implement it. I have Google and BING so many article about keyboard shortcut in Silverlight. What I thought If I can do in Silverlight then I can definitely do in LightSwitch Silverlight Client. Now my requirement is to focus on various TabItem located in my screen by pressing custom keyboard key. I think I have seen many LightSwitch Forum article where people have asked so many times. Why not this is also a requirement for faster data entry in Business Application. So I pulled my hair couple of time and start the magic. Here we go...
1. I opened the screen where I have multiple tabitem controls. Within the Screen_Created method wrote the below code. My screen Name is "VoucherDetail".
partial void VouchersDetail_Created() { // Write your code here. this.FindControl("ScreenLayout").ControlAvailable += JournalVoucher_ControlAvailable; }Here "ScreenLayout" is my screen control name. I thought I have to get control on screen first.
void JournalVoucher_ControlAvailable(object sender, ControlAvailableEventArgs e) { ((System.Windows.Controls.Grid)e.Control).KeyUp += JournalVoucher_KeyUp; } void JournalVoucher_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Z) { if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { this.FindControl("ReceiptVouchers").Focus(); } } if (e.Key == Key.C) { if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { this.FindControl("PaymentVouchers").Focus(); } } if (e.Key == Key.X) { if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { this.FindControl("OtherVouchers").Focus(); } } }
Here "ReceiptVouchers", "PaymentVouchers", "OtherVouchers" are the TabItem controls in my screen. Below is the image.
After all that I debug the application and opened the screen and press Ctrl+Z. Ypeeeeeeeee. It works. Now other two Ctrl+C and Ctrl+X, yes these are also working.
Hmmmm, Now time to have a cup of tea.
Hope you enjoy it...
I will highly appreciate to comment on this.
As Jan said, Keep Rocking LightSwitch.
Thank You...
