WPF 允许我使用 InputBindings 属性轻松地将窗口级别的键盘快捷键绑定(bind)到方法。这在 WinRT 中的等价物是什么?将键盘快捷键绑定(bind)到 WinRT 中的方法的正确方法是什么?
最佳答案
here 描述了键盘快捷键。我想你想要 access keys 或 accelerator keys 。
<MediaElement x:Name="Movie" Source="sample.wmv"
AutoPlay="False" Width="320" Height="240"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button x:Name="Play" Margin="1,2"
ToolTipService.ToolTip="shortcut key: Ctrl+P"
AutomationProperties.AccessKey="Control P">
<TextBlock><Underline>P</Underline>lay</TextBlock>
</Button>
<Button x:Name="Pause" Margin="1,2"
ToolTipService.ToolTip="shortcut key: Ctrl+A"
AutomationProperties.AccessKey="Control A">
<TextBlock>P<Underline>a</Underline>use</TextBlock>
</Button>
<Button x:Name="Stop" Margin="1,2"
ToolTipService.ToolTip="shortcut key: Ctrl+S"
AutomationProperties.AccessKey="Control S">
<TextBlock><Underline>S</Underline>top</TextBlock>
</Button>
</StackPanel>
<object AutomationProperties.AcceleratorKey="ALT+F" />
有关代码方面的实现细节,请参阅@Magiel 的回答。
关于c# - 什么是WinRT的InputBindings等效项?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11554715/