单个RoutedUICommand的多个KeyGestures

时间:2016-05-03 17:11:38

标签: c# wpf .net-4.0

单个KeyGestures可以有2个或更多RoutedUICommand吗?

例如:用户希望能够按 Space Alt + P 播放视频。

目前,如果我同时将KeyGestures设置为RoutedUICommand,则会强制要求两者都执行。

private static RoutedUICommand _play  = new RoutedUICommand("Play", "Play", typeof(Commands), 
   new InputGestureCollection 
       { 
            new KeyGesture(Key.P, ModifierKeys.Alt, "Alt + P"),
            new KeyGesture(Key.Space, ModifierKeys.None, "Space")
       });

那么,我可以将多个KeyGestures设置为一个RoutedUICommand吗?如果是这样,怎么样?

1 个答案:

答案 0 :(得分:1)

是的,你可以为同一个命令添加多个keyBinding,如下所示,

library(ggplot2)

chart1_data <- data.frame(year=c("1998","1998","1998","1998","1998","1998","1998","1998","1998"), medicine=c("Fent","Meth","Morph","Fent","Meth","Morph","Fent","Meth","Morph"), entity=c("Italy","Italy","Italy","Norway","Norway","Norway","Portugal","Portugal","Portugal"), usage=c(3.01,9.32,2.01,1.24,1.43,28.48,5.01,5.51,41.82))

chart1_means <- data.frame(label=c("Global Fent","EURO Fent","Global Meth","EURO meth","Global Morph","EURO Morph"), value=c(0.03, 0.07, 1.59, 5.12, 3.28, 8.54))

means_labels = chart1_means$label
colors = rainbow(length(means_labels))

ggplot(data=chart1_data, aes(x=entity, y=usage, fill=medicine)) +
geom_bar(stat="identity", position=position_dodge(), show.legend=TRUE) +
geom_hline(data=chart1_means, aes(yintercept=value), color=colors) +
scale_fill_manual("means", values=colors, guide=guide_legend(override.aes = list(colors)))