Skip to content

Latest commit

 

History

History
46 lines (33 loc) · 1.84 KB

KeyDownTriggerBehavior.md

File metadata and controls

46 lines (33 loc) · 1.84 KB
title author description keywords dev_langs
Key Down Trigger Behavior
XAML-Knight
Add a new behavior that listens to a key press event on the associated UIElement and triggers the set of actions.
windows 10, uwp, windows community toolkit, uwp community toolkit, uwp toolkit, textbox, behaviors, interactivity, KeyDownTrigger, key down trigger
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: Behaviors

[!div class="nextstepaction"] Try it in the sample app

Example

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

  <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. You can see this in action in Windows Community Toolkit Sample App.

Source Code

Related Topics