using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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.Navigation;
using System.Windows.Shapes;
namespace clipper
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
public void HandleKeyDownEvent(object sender, KeyEventArgs e)
{
MessageBox.Show("It came here");
if (e.Key == Key.LeftCtrl && e.Key == Key.C)
{
MessageBox.Show("You have pressed control + c");
}
}
}
}
이것은 내 코드입니다. 나는 keyPress 이벤트에 대한 솔루션 검색을 시도하고 여기 그것을 구현했습니다. 그러나 C#을 처음 접했을 때 나는 무엇이 잘못되었는지 확신하지 못했습니다. 나를 안내 해줘.나는 C# wpf에서 키 스트로크를 얻으려고하는데 작동하지 않는다. 코드가 잘못 되었나요?
나는 Form ...을 사용하지 않고있다. 나는 wpf를 사용하고있다. 아마도 내가 KeyPreview = ture; – laslavinco
이뿐 아니라 이벤트를 첨부하는 것을 잊었습니다 :'this.KeyPreview = true; this.KeyPress + = 새 KeyPressEventHandler (HandleKeyDownEvent); – SilentStorm