zoukankan      html  css  js  c++  java
  • CommandBinding用法

    .cs文件中用法 

    private void BindCommands()
            {
                //[OK]
                CommandBinding cb = new CommandBinding(Commands.OK, OnOK);
                this.CommandBindings.Add(cb);
                this.OkButton.Command = Commands.OK;
                //[CANCEL]
                cb = new CommandBinding(Commands.Cancel, OnCancel);
                this.CommandBindings.Add(cb);
                this.CancelButton.Command = Commands.Cancel;          
            }

    然后在构造函数中调用即可。 

    .xmal中用法

    先在.cs文件中定义:        public static RoutedCommand CloseCommand = new RoutedCommand();

      <Window.CommandBindings>
        <CommandBinding Command="path:fileName.CloseCommand" Executed="Click_OK"/>
      </Window.CommandBindings>
      <Window.InputBindings>
        <KeyBinding Command="path:fileName.CloseCommand" Gesture="Escape"/>
        <KeyBinding Command="path:fileName.CloseCommand" Gesture="Enter"/>
      </Window.InputBindings>

  • 相关阅读:
    Linux Apache服务(一)
    mysql基础
    linux面试题一
    linux shell(2)
    linux基础汇总2
    python列表生成式、生成器,迭代器与二分法
    python的函数
    python函数
    java 翁老师学习笔记-持续更
    责任链模式
  • 原文地址:https://www.cnblogs.com/sizzle/p/891915.html
Copyright © 2011-2022 走看看