Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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.