这是我的第一个C# (也是第一个Windows)应用程序。我想对多键命令做出反应,但不知道怎么回事。web上的示例使用e.Modifiers、e.Control和override bool ProcessCmdKey,其中没有一个选项出现在我的IDE中。我的主要课程是System.Windows.Window,所以这就是问题所在吗?我一直在读关于Forms的书--我在利用这个吗?
这是我的班级首页信息。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Serialization;
using System.Text;
using System.IO;
using System.Configuration;
using System.Threading.Tasks;
using System.Windows;
using Microsoft.WindowsAPICodePack.Dialogs;
//using System.Windows.Forms.
using Winforms = System.Windows.Forms;
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.Navigation;
using System.Runtime.Serialization.Formatters.Binary;
namespace ContractCutter
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
...这就是我尝试做事情的地方。我也只有Key类,而不是Keys类。
void CutContractKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.LeftCtrl)
stuff;
}发布于 2014-10-14 13:09:57
你可以用这个:
private void CutContractKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.S && Keyboard.Modifiers == ModifierKeys.Control)
{
MessageBox.Show("CTRL + S");
}
}https://stackoverflow.com/questions/26361441
复制相似问题