WPF界面中添加“快捷键”(比如F5是刷新功能)

<UserControl>

<Control.InputBindings>
        <KeyBinding Gesture="Ctrl+N" Key="N" Command="{Binding Path=Add}"/> (比如一起按Ctrl+n,就会执行绑定的Add事件,当然绑定的事件可以自己起名字,按钮也可以自己规定哪个键执行这个事件)  Gesture就是规定的哪个键,Command=“ {Binging Path=自己起得事件名字(当然此事件需要在后台自己写)}” 
        <KeyBinding Gesture="Ctrl+E" Key="E" Command="{Binding Path=Modify}"/>
        <KeyBinding Gesture="Delete" Key="Delete" Command="{Binding Path=Delete"/>
        <KeyBinding Gesture="F5" Key="F5" Command="{Binding Path=Refresh}"/>(这个就是所说的按F5执行刷新功能,这里绑定的是Refresh事件,当然可以自己起名字)
</Control.InputBindings>

<Grid>

</Grid>

</UserControl>

这个是在UserControl中添加的快捷键。其它的类似。

posted @ 2013-03-25 09:15  Latent_Truth  阅读(885)  评论(0编辑  收藏  举报