locked
Does Windows store device application support Hot key implementation?

    Question

  • Hi,

    I am trying to implement Hot key of my Windows store application. I am not getting Key , KeyEventArgs (System.Windows.Input) as a using. I like to use AdornerLayer(System.Windows.Documents) but can't use in windows store app project.

    Is it possible to implement hotkey in windows store application?

    Regards,

    San

    Saturday, June 14, 2014 11:13 AM

Answers

  • I'm not aware of any specific sample code on this and there are several ways, depending on how complicated you need it to be.

    You can create a transparent "AdornerLayer" panel on top of your page and then place your adorners on it. If you want your adornments to all be text based you could create an attached property for the text and set that on your controls. The attached property could create a TextBlock in an appropriate position as a child of the AdornerLayer. You could also let this allow any UIElement, but that would be more complicated, or you could hardcode the adornments in Xaml at the cost of flexibility.

    Set up visual states for the AdornerLayer to default to Opacity 0 and to animate to Opacity 1.0 when the adorners should be shown.

    --Rob

    Thursday, June 19, 2014 12:38 AM
    Owner

All replies

  • Hey sansmile,

    I am using the following code to get key events:

    CoreWindow.GetForCurrentThread().KeyDown += KeyDownEventHandler;

    Hope that helps.

    Jan

    • Proposed as answer by Dave SmitsMVP Monday, June 16, 2014 6:34 AM
    Saturday, June 14, 2014 1:45 PM
  • Hi,

    You can refer to the links below:

    http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh868246.aspx

    http://www.michielpost.nl/PostDetail_71.aspx

    Basically you would handle Window.Current.CoreWindow.KeyDown/Up, store the current state of the modifier keys (Ctrl, Alt, Shift) and respond to combinations to handle them.

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, June 16, 2014 2:16 AM
  • Hi,

    OK. Up/Down key problem got resolve now. But how do I identify it is a LeftAlt/RightAlt key?? I didn't find it inside "Windows.System.VirtualKey" ?

    Now How do I get framework element layer where I will display the Hotkey when user press "Alt". One way is to get the AdornerLayer [AdornerLayer.GetAdornerLayer()]of the framework element, that I usually do in desktop UI. But in case of WSDA, i didn't find  AdornerLayer. Please suggest what I need to do to display Hotkey in WSDA app??

    Thanks & Regards,

    San 


    • Edited by sansmile Monday, June 16, 2014 1:00 PM
    Monday, June 16, 2014 12:46 PM
  • There is no adorner layer. Windows Store apps cannot use WPF classes. The adorner layer is specific to WPF.

    You can get a similar effect by hiding or showing your adorners with Visual States.

    --Rob

    Monday, June 16, 2014 3:08 PM
    Owner
  • Is there any example code available in MSDN? from where I can get some thought or idea to develop adorners with visual states in Windows Store applications. If you provide some link it will help me

    -San

    Tuesday, June 17, 2014 4:37 AM
  • I'm not aware of any specific sample code on this and there are several ways, depending on how complicated you need it to be.

    You can create a transparent "AdornerLayer" panel on top of your page and then place your adorners on it. If you want your adornments to all be text based you could create an attached property for the text and set that on your controls. The attached property could create a TextBlock in an appropriate position as a child of the AdornerLayer. You could also let this allow any UIElement, but that would be more complicated, or you could hardcode the adornments in Xaml at the cost of flexibility.

    Set up visual states for the AdornerLayer to default to Opacity 0 and to animate to Opacity 1.0 when the adorners should be shown.

    --Rob

    Thursday, June 19, 2014 12:38 AM
    Owner