0
我有我的创建自定义命令New
,Edit
和Delet
,我在InputBinding
设置此热键,但它是非常辛苦的工作,当我需要用我的命令每次如何设置自定义命令的默认热键?
Copy
命令的例子,我不需要设置热键,但它具有默认热键Ctrl + C
如何为我的客户命令设置默认热键Ctrl + N,Ctrl + E和Ctrl + D?
public static class HWCommand
{
static RoutedUICommand save = new RoutedUICommand("Save", "Save", typeof(HWCommand));
static RoutedUICommand novo = new RoutedUICommand("Novo", "Novo", typeof(HWCommand));
static RoutedUICommand deletar = new RoutedUICommand("Deletar", "Deletar", typeof(HWCommand));
static RoutedUICommand editar = new RoutedUICommand("Editar", "Editar", typeof(HWCommand));
public static RoutedUICommand Save { get { return save; } }
public static RoutedUICommand Novo { get { return novo; } }
public static RoutedUICommand Deletar { get { return deletar; } }
public static RoutedUICommand Editar { get { return editar; } }
}
我的CommandBinding
<Window.CommandBindings>
<CommandBinding Command="{x:Static hw:HWCommand.Novo}" Executed="NovoCommand_Executed"/>
<CommandBinding Command="{x:Static hw:HWCommand.Editar}" Executed="EditarCommand_Executed" CanExecute="EditCommand_CanExecuted"/>
<CommandBinding Command="{x:Static hw:HWCommand.Deletar}" Executed="DeletarCommand_Executed" CanExecute="DeletarCommand_CanExecuted"/>
</Window.CommandBindings>
谢谢英语新太多了!这是工作!但是......其他问题......它接受InputGestureCollection,那么我可以为这个命令设置多个热键吗? – Lai32290
从技术上讲,你可以把'InputGestures'的整个列表包括['KeyGestures'](http://msdn.microsoft.com/en-us/library/system.windows.input.keygesture.aspx),但是这个I没有尝试,['MouseGesture'](http://msdn.microsoft.com/en-us/library/system.windows.input.mousegesture.aspx) – dkozl