WPF控件中的标准键盘快捷键 [英] Standard keyboard shortcuts in WPF controls

查看:106
本文介绍了WPF控件中的标准键盘快捷键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对WPF控件的所有可用快捷方式列表感兴趣.我主要对WPF TreeView控件的标准快捷方式感兴趣(例如,全部展开/折叠,全部选中等),但似乎找不到列出它们的任何位置.是否有特定的页面列出了WPF控件的可用快捷方式?

I'm interested in a list of all available shortcuts of WPF controls. I was mainly interested in the standard shortcuts for WPF TreeView control (e.g., expand/collapse all, select all and so on), but I can't seem to find any location that lists them. Is there a specific page listing available shortcuts for WPF controls?

我知道一些天真的支持快捷方式,例如, Ctrl + A 将选择给定ListView控件中的所有行.

I know some shortcuts are supported naively, e.g., Ctrl + A will select all rows in a given ListView control.

我可以定义自己的快捷方式并实现其行为.但是,我认为定义.NET框架已支持的快捷方式不是一个好习惯,因此需要了解此类支持的快捷方式.

I could define my own shortcuts and implement their behaviour. However, I feel it is not a good practice to define shortcuts that are already supported by the .NET framework and hence the need to know about such supported shortcuts.

在其他情况下,我通常会使用Visual Studio中与WPF应用程序相同的快捷方式,但是我希望在这里获得WPF控件中开箱即用支持的快捷方式的更详细列表.

In other situations I would typically use the same shortcuts available in Visual Studio as it is a WPF application, but I am hopping here for a more extensive list of out of the box supported shortcuts in WPF controls.

推荐答案

据我所知,尚无受支持的快捷方式的主列表,您很正确地认为它们通常将从Windows中的基本快捷方式继承其快捷方式.我以前曾经自己搜索过此文件,但从未找到过列表.我在网上看到的其他人也从未有过运气.

As far as I know, there is no master list of supported shortcuts, and you are right that they in general will inherit their shortcuts from the basic shortcuts in Windows. I have searched for this on my own before and have never been able to locate a list. Others I have seen asking on the internet have also never had any luck.

因此,不幸的答案是:不,没有列表.

So the unfortunate answer is: No, there is no list.

好的,经过一番挖掘,我能提供给您的最好的是可以应用于WPF内置控件的预定义命令列表.这些分为五类:

OK, after some digging, the best I can give you is a list of pre-defined commands that you can apply to your controls that are built into WPF. These come in five categories:

  • 应用程序命令
  • 导航命令
  • 组件命令
  • 媒体命令
  • 编辑命令

可以在MSDN 将此作为其键手势"属性.

Their documentation can be found on MSDN here (an example). Clicking on one of the commands will take you to its individual page which will list their default shortcut like this as its "Key Gesture" property.

您可以将这些默认命令分配给控件,如下所示:

You can assign these default commands to controls like so:

  <Button Command="ApplicationCommands.Cut" CommandTarget="{Binding ElementName=txtEditor}" Width="60">_Cut</Button>
  <Button Command="ApplicationCommands.Paste" CommandTarget="{Binding ElementName=txtEditor}" Width="60" Margin="3,0">_Paste</Button>

是关于将这些命令绑定到按钮,而不是其他内容(该代码来自何处).该 会告诉您默认情况下有哪些命令,但是无论该命令值多少,它至少应该能够推断出其中一些命令的键盘快捷键.

This is a seemingly pretty basic tutorial on binding these commands to buttons and what not (where that code is from). This doesn't tell you what commands are there by default, but it should be able to at least deduce the keyboard shortcuts for some of these commands, for whatever that's worth.

这篇关于WPF控件中的标准键盘快捷键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆