我想檢查C#Windows窗體應用程序中插入鍵的狀態。下面是最少的代碼(不工作;形式有兩個單選按鈕):確定Windows窗體應用程序中的插入模式
using System;
using System.Windows.Forms;
using System.Windows.Input;
// Also added PresentationCore and WindowsBase refereneces
namespace InsertModeDemo1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
if (Keyboard.IsKeyToggled(Key.Insert))
radioButtonInsert.Checked = true;
else
radioButtonOverstrike.Checked = true;
}
}
}
爲什麼在winforms中包含wpf相關的程序集? –
這些程序集中的鍵盤和鍵名稱空間 –