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
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
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for