简单的WPF问题 [英] Simple WPF Question
本文介绍了简单的WPF问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一组单选按钮,我希望用户能够使用F键去按下它们,即第一个组是F1,F2,F3,F4.
有没有比创建一个命令来按下每个命令然后使用InputBinding更简单的方法?
即我可以写一些XAML说-``在F1上按单选按钮1''吗?
在此先感谢!!
I have a set of radio buttons, I want the user to be able to go press them with the F keys, i.e group one is F1, F2, F3, F4.
Is there an easier way than creating a command for to press each one and then using an InputBinding?
i.e. can I write some XAML that says - ''on F1 press radio button 1''?
Thanks in advance!!
推荐答案
我不确定我是否理解您的问题,但是无论如何我都会尝试回答.
为什么不在您的Xaml窗口中添加keydown/keyup事件?
然后是C#代码.
I am not sure i understand your question but i will try to answer it anyway.
Why not add a keydown/keyup event on your Xaml window?
and then C# Code behind it.
private void Window_KeyUp(object sender, KeyEventArgs e)
{
switch(e.Key)
{
case Key.F1:
radioButton1.IsChecked = true;
break;
case Key.F2:
radioButton2.IsChecked = true;
break;
case Key.F3:
radioButton3.IsChecked = true;
break;
case Key.F4:
radioButton4.IsChecked = true;
break;
}
}
这篇关于简单的WPF问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文