[英]WPF Add KeyBinding events with umlaut characters in XAML
我编写了一个小型测试程序,以找出哪个Key
是什么。 制作新的WPF项目并添加到主窗口cs文件中:
public MainWindow()
{
InitializeComponent();
var skip = new[] { Key.None, Key.DeadCharProcessed };
foreach (Key value in Enum.GetValues(typeof(Key)))
if (!skip.Contains(value))
InputBindings.Add(new KeyBinding { Command = new MyCommand(value.ToString()), Key = value });
}
public class MyCommand : ICommand
{
public event EventHandler CanExecuteChanged;
public string Text { get; }
public MyCommand(string text) { Text = text; }
public bool CanExecute(object parameter) => true;
public void Execute(object parameter) => MessageBox.Show(Text);
}
为节省时间:
Ü = Key.Oem1
Ö = Key.Oem3
Ä = Key.OemQuotes
由于KeyBinding.Key
是枚举,因此您可以在此处查看所有可能的值。 由于您的变音符不是该枚举的一部分-您不能使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.