C#、WPF下实现普通快捷键的方法
2012-04-05 02:05
176 查看
普通快捷键只要在后台添加即可
代码如下
代码如下
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace WpfDataGrid { /// <summary> /// Interaction logic for Window2.xaml /// </summary> public partial class Window2 : Window { public Window2() { InitializeComponent(); this.Loaded += new RoutedEventHandler(Window2_Loaded); } void Window2_Loaded(object sender, RoutedEventArgs e) { this.PreviewKeyDown += new KeyEventHandler(Window2_PreviewKeyDown); button1.Click += new RoutedEventHandler(button1_Click); } void button1_Click(object sender, RoutedEventArgs e) { MainWindow main = new MainWindow(); main.ShowDialog(); } void Window2_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.F1) { button1_Click(this, null); } } } }本文来自CSDN博客,出处:http://blog.csdn.net/rose_liang/archive/2011/04/28/6369274.aspx
相关文章推荐
- C#下的单例实现本文介绍了C#下关于单例的三种实现方法。 最普通的一种: 以下是引用片段: using System; public class Singleton { pr
- C#实现快捷键的几种常用方法汇总
- 深入理解C#实现快捷键(系统热键)响应的方法
- C#实现全局热键响应,失去焦点情况下响应全局快捷键的方法
- C#(WPF和WinForm)在普通类中调用到主线程的方法,SynchronizationContext的用法。
- 实现方法 C# button快捷键
- 【笔记】C#实现快捷键(系统热键)响应的方法
- C# 实现快捷键几种方法
- 【C#/WPF】WPF应用程序,另一类Button按钮(图片)的实现方法。
- C#实现全局热键响应,失去焦点情况下响应全局快捷键的方法
- 如何实现C++调用C#的dll方法教程
- C#三种模拟自动登录和提交POST信息的实现方法
- C#实现图片分割方法与代码
- C#中winform实现自动触发鼠标、键盘事件的方法
- 使用C#实现在word中插入页眉页脚的方法
- 判断一个字符串是否全是数字的多种方法及其性能比较(C#实现)--来源CSDN
- c#实现隐藏与显示任务栏的方法详解
- C#中计时器的简单实现方法示例
- KMP算法的C#实现方法
- 使用C#反射实现用户控件调用父页面方法