WPF让button响应按键
2015-06-24 19:36
281 查看
在xmal中加入,响应回车键,其它键类似
<Window.Resources>
<RoutedUICommand x:Key="ClickCommand" Text="Text" />
</Window.Resources>
<Window.CommandBindings>
<CommandBinding Command="{StaticResource ClickCommand}" Executed="EnterHandler" />
</Window.CommandBindings>
<Window.InputBindings>
<KeyBinding Key="Enter" Command="{StaticResource ClickCommand}" />
</Window.InputBindings>
在cs文件中加入函数
private void EnterHandler(object sender, RoutedEventArgs e)
{
//handle click event,加入想要实现的功能
}
<Window.Resources>
<RoutedUICommand x:Key="ClickCommand" Text="Text" />
</Window.Resources>
<Window.CommandBindings>
<CommandBinding Command="{StaticResource ClickCommand}" Executed="EnterHandler" />
</Window.CommandBindings>
<Window.InputBindings>
<KeyBinding Key="Enter" Command="{StaticResource ClickCommand}" />
</Window.InputBindings>
在cs文件中加入函数
private void EnterHandler(object sender, RoutedEventArgs e)
{
//handle click event,加入想要实现的功能
}
相关文章推荐
- OJ第二批——Problem D:友元类-计算两点间的距离
- IDL box plot
- objective-c字符串笔记
- 如何实现QT程序开机自启动
- win32 ListView控件
- 关于Android自定义控件详解
- UILabel和UITableview自定义分割线
- objective-c数组笔记
- 序列判断
- 转载:程序内存分配 堆栈
- 字符串与日期对象相互转换
- 设置SOCKET的发送与接收缓冲区
- WPF只能输入数字
- 数组与字典之间的调用笔记
- apache安装webalizer步骤
- OpenGL ES2.0---凿岩车钻臂3D案例之MatrixState类详解
- POJ 1655 Balancing Act (树的重心)
- iOS使用NSOperation创建线程
- 高德地图SDK使用说明
- iOS JS与iOS的函数互调