<Window.InputBindings>
<KeyBinding Key="0" Command="{Binding ZeroCommand}"/>
<KeyBinding Key="1" Command="{Binding OneCommand}"/>
<KeyBinding Key="2" Command="{Binding TwoCommand}"/>
<KeyBinding Key="3" Command="{Binding ThreeCommand}"/>
<KeyBinding Key="4" Command="{Binding FourCommand}"/>
<KeyBinding Key="5" Command="{Binding FiveCommand}"/>
<KeyBinding Key="6" Command="{Binding SixCommand}"/>
<KeyBinding Key="7" Command="{Binding SevenCommand}"/>
<KeyBinding Key="8" Command="{Binding EightCommand}"/>
<KeyBinding Key="9" Command="{Binding NienCommand}"/>
<KeyBinding Key="OemPlus" Command="{Binding PlusCommand}"/>
<KeyBinding Key="OemMinus" Command="{Binding MinusCommand}"/>
<KeyBinding Key="OemBackslash" Command="{Binding DevideCommand}"/>
<KeyBinding Key="Multiply" Command="{Binding MultiplyCommand}"/>
<KeyBinding Key="Return" Command="{Binding EqualsCommand}"/>
</Window.InputBindings>
当我遇到这个问题时,我正在创建一个基本的计算器应用程序。我收到编译错误'0'不能用作'Key'的值。数字不是有效的枚举值。事实上,OemMinus是唯一被绑定的命令。
我认为可以通过创建一个带单例的InputBindingConfiguration类来解决这个问题,在那里定义键并绑定到那些键但是我想知道是否有一种纯粹在Xaml中执行此操作的方法?
答案 0 :(得分:0)