奔跑的牛排 发表于 2013-1-3 15:35:25

WPF 公用快捷键

<div id="cnblogs_post_body">       如果没用WPF MVVM模式,那WPF提供的快捷键绑定用起很麻烦,在此封装了一个公用快捷键,支持XAML绑定。
XAML用法:
<div class="cnblogs_code" style="text-align: left;"><Button Shortcutkeys:ShortcutkeyService.IsEnabledShortcutkey="True" Content="Ctrl+A(Self Focus|Click Event)" Click="Button_Click" HorizontalAlignment="Left" Margin="120,55,0,0" VerticalAlignment="Top" Width="200">    <Shortcutkeys:ShortcutkeyService.Shortcutkeys>      <Shortcutkeys:ShortcutkeyCollection>            <Shortcutkeys:ShortcutkeyToCurrent Gesture="Ctrl+A" EventType="Click"/>      </Shortcutkeys:ShortcutkeyCollection>    </Shortcutkeys:ShortcutkeyService.Shortcutkeys></Button><Button Shortcutkeys:ShortcutkeyService.IsEnabledShortcutkey="True" Content="Ctrl+C(Control Name Focus)" Click="Button_Click" HorizontalAlignment="Left" Margin="120,164,0,0" VerticalAlignment="Top" Width="200">    <Shortcutkeys:ShortcutkeyService.Shortcutkeys>      <Shortcutkeys:ShortcutkeyCollection>            <Shortcutkeys:ShortcutkeyToElementName Gesture="Ctrl+C" ElementName="Layout" EventType="Click" />      </Shortcutkeys:ShortcutkeyCollection>    </Shortcutkeys:ShortcutkeyService.Shortcutkeys></Button>
页: [1]
查看完整版本: WPF 公用快捷键