zoukankan      html  css  js  c++  java
  • Shortcut key for WPF

    steps:

    open the window code page, and find the construction function;

    add code like below:

     public MainWindow()
            {
                InitializeComponent();

                
    // Create the CommandBinding.
                CommandBinding cmd = new CommandBinding();
                cmd.Command 
    = ApplicationCommands.New;

                cmd.Executed 
    += new ExecutedRoutedEventHandler(CommandBinding_CmdKey_Executed);
                cmd.CanExecute 
    += new CanExecuteRoutedEventHandler(CommandBinding_CmdKey_CanExecute);
                
    this.CommandBindings.Add(cmd);
                
    // Creating a KeyBinding between the Open command and Ctrl-R
                KeyBinding CmdKey = new KeyBinding();
                CmdKey.Key 
    = Key.F;
                CmdKey.Modifiers 
    = ModifierKeys.Control;
                CmdKey.Command 
    = cmd.Command;
                
    this.InputBindings.Add(CmdKey);
            }
            
    private void CommandBinding_CmdKey_CanExecute(object sender, CanExecuteRoutedEventArgs e)
            {
                e.CanExecute 
    = true;
            }

            
    private void CommandBinding_CmdKey_Executed(object sender, ExecutedRoutedEventArgs e)
            {
                MessageBox.Show(
    "OK");
            }
  • 相关阅读:
    dotnet 使用 MessagePack 序列化对象
    dotnet 使用 MessagePack 序列化对象
    PHP die() 函数
    PHP defined() 函数
    PHP define() 函数
    PHP constant() 函数
    PHP connection_status() 函数
    查看物理CPU个数、核数、逻辑CPU个数
    CF997C Sky Full of Stars
    dotnet 使用 lz4net 压缩 Stream 或文件
  • 原文地址:https://www.cnblogs.com/skyfei/p/2009047.html
Copyright © 2011-2022 走看看