keydown 上的 UWP 触发命令?
UWP trigger command on keydown?
我正在尝试在用户按下某个键时执行命令:
<TextBox Command="{Binding myCommand}" Height="200" Width="200" FontSize="20"></TextBox>
现在使用 UWP 我不完全确定这是如何完成的。在 WPF 中,我们有键绑定,但在这里呢?如果可能,没有第三方库。你们会如何解决这个问题?我不想重新发明轮子并创建我自己的适用于此类边缘情况的命令实现。
如果没有,请安装 Behaviors NuGet,然后:
<TextBox Height="200" Width="200" FontSize="20">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="KeyDown">
<Core:InvokeCommandAction Command="{Binding myCommand}" />
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</TextBox>
我正在尝试在用户按下某个键时执行命令:
<TextBox Command="{Binding myCommand}" Height="200" Width="200" FontSize="20"></TextBox>
现在使用 UWP 我不完全确定这是如何完成的。在 WPF 中,我们有键绑定,但在这里呢?如果可能,没有第三方库。你们会如何解决这个问题?我不想重新发明轮子并创建我自己的适用于此类边缘情况的命令实现。
如果没有,请安装 Behaviors NuGet,然后:
<TextBox Height="200" Width="200" FontSize="20">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="KeyDown">
<Core:InvokeCommandAction Command="{Binding myCommand}" />
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</TextBox>