码迷,mamicode.com
首页 > Windows程序 > 详细

WPF 快捷键

时间:2019-12-21 00:10:10      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:man   and   keyword   btn   alignment   fun   message   system   wpf   

原文:WPF 快捷键

<p><pre name="code" class="csharp"> 
前台

<Window.Resources>

<RoutedUICommand x:Key="btnClick" Text="Button Click"/> </Window.Resources> <Window.InputBindings> <KeyBinding Gesture="Ctrl+F" Key="F" Command="{StaticResource btnClick}"/> </Window.InputBindings> <Window.CommandBindings> <CommandBinding Command="{StaticResource btnClick}" CanExecute="CommandBinding_CanExecute" Executed="CommandBinding_Executed"/> </Window.CommandBindings> <Grid> <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="105,76,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" /> </Grid>





后台

  1. private void button1_Click(object sender, System.Windows.RoutedEventArgs e)
  2. {
  3. MessageBox.Show("sss");
  4. }
  5. private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
  6. {
  7. e.CanExecute = true;
  8. }
  9. private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
  10. {
  11. button1_Click(this, null);
  12. }


      

WPF 快捷键

标签:man   and   keyword   btn   alignment   fun   message   system   wpf   

原文地址:https://www.cnblogs.com/lonelyxmas/p/12075377.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!