Caliburn Micro 键盘快捷键不起作用
Caliburn Micro keyboard shortcuts not working
给出以下 XAML:
<UserControl x:Class="Solution.Views.SomeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:cm="http://www.caliburnproject.org"
cm:Message.Attach="[Key F11] = [ToggleFullScreen]">
<Grid>
<ToolBar DockPanel.Dock="Top" Margin="0">
<xctk:IconButton Style="{StaticResource ToolBarButton}" ToolTip="Full Screen (F11)"
cm:Message.Attach="ToggleFullScreen">
<Image Style="{StaticResource ToolBarButtonImage}" Source="pack://application:,,,/Resources/Img/Full_Screen32.png"/>
</xctk:IconButton>
</ToolBar>
</Grid>
</UserControl>
F11 不会触发 ToggleFullScreen
方法,但单击按钮会。将 [Key F11] 更改为 [Gesture Alt+F] 或 [Gesture F11] 也不起作用...
这是为什么?如何获得与 Caliburn Micro 3.2.0 一起使用的键盘快捷键?
看看 GitHub 上的官方 Scenario.KeyBinding 示例。特别注意Bootstrapper
class中的Configure()
方法。它是启用键绑定的代码。如果在示例项目中的ShellViewModel
class中添加ToggleFullScreen()
方法,并将ShellView
的cal:Message.Attach
attached属性设置为[Key F11] = [ToggleFullScreen]
就像您在示例中所做的那样,它应该可以工作。
因此您需要将Configure()
方法中的代码复制到您的引导程序中,并将示例项目Input
文件夹下的classes引入您的项目中。
给出以下 XAML:
<UserControl x:Class="Solution.Views.SomeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:cm="http://www.caliburnproject.org"
cm:Message.Attach="[Key F11] = [ToggleFullScreen]">
<Grid>
<ToolBar DockPanel.Dock="Top" Margin="0">
<xctk:IconButton Style="{StaticResource ToolBarButton}" ToolTip="Full Screen (F11)"
cm:Message.Attach="ToggleFullScreen">
<Image Style="{StaticResource ToolBarButtonImage}" Source="pack://application:,,,/Resources/Img/Full_Screen32.png"/>
</xctk:IconButton>
</ToolBar>
</Grid>
</UserControl>
F11 不会触发 ToggleFullScreen
方法,但单击按钮会。将 [Key F11] 更改为 [Gesture Alt+F] 或 [Gesture F11] 也不起作用...
这是为什么?如何获得与 Caliburn Micro 3.2.0 一起使用的键盘快捷键?
看看 GitHub 上的官方 Scenario.KeyBinding 示例。特别注意Bootstrapper
class中的Configure()
方法。它是启用键绑定的代码。如果在示例项目中的ShellViewModel
class中添加ToggleFullScreen()
方法,并将ShellView
的cal:Message.Attach
attached属性设置为[Key F11] = [ToggleFullScreen]
就像您在示例中所做的那样,它应该可以工作。
因此您需要将Configure()
方法中的代码复制到您的引导程序中,并将示例项目Input
文件夹下的classes引入您的项目中。