Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add markdown documentation for new KeyDownTriggerBehavior #556

Merged
merged 6 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions docs/behaviors/KeyDownTriggerBehavior.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: Key Down Trigger Behavior
author: XAML-Knight
description: Add a new behavior that listens to a key press event on the associated UIElement and triggers the set of actions.
keywords: windows 10, uwp, windows community toolkit, uwp community toolkit, uwp toolkit, textbox, behaviors, interactivity, KeyDownTrigger, key down trigger
dev_langs:
- csharp
---

# Key Down Trigger Behavior

Add a new behavior that listens to a key press event on the associated UIElement and triggers the set of actions.

> **Platform APIs:** [`KeyDownTriggerBehavior`](/dotnet/api/microsoft.toolkit.uwp.ui.behaviors.keydowntriggerbehavior)

> [!div class="nextstepaction"]
> [Try it in the sample app](uwpct://Helpers?sample=KeyDownTriggerBehavior)

## Example

In this example setting up the `KeyDownTriggerBehavior` to start the animation:

```xaml
<TextBox
PlaceholderText="Set the focus to this TextBox and press enter to trigger the animation"
Width="500">
<interactivity:Interaction.Behaviors>
<behaviors:KeyDownTriggerBehavior
Key="Enter">
<behaviors:StartAnimationAction Animation="{Binding ElementName=MoveAnimation}" />
</behaviors:KeyDownTriggerBehavior>
</interactivity:Interaction.Behaviors>
</TextBox>
```

## Sample Project

[Key Down Trigger behavior sample page Source](https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/main/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/KeyDownTriggerBehavior). You can [see this in action](uwpct://Helpers?sample=KeyDownTriggerBehavior) in [Windows Community Toolkit Sample App](https://aka.ms/windowstoolkitapp).

## Source Code

- [Key Down Trigger behavior source code](https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/main/Microsoft.Toolkit.Uwp.UI.Behaviors/Keyboard)

## Related Topics

- [XAML Behaviors](https://github.com/microsoft/XamlBehaviors/wiki)
2 changes: 2 additions & 0 deletions docs/toc.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@

### [Header Behaviors](behaviors/HeaderBehaviors.md)

### [Key Down Trigger Behavior](behaviors/KeyDownTriggerBehavior.md)

### [ImageCache](helpers/ImageCache.md)

### [IncrementalLoadingCollection](helpers/IncrementalLoadingCollection.md)
Expand Down