zoukankan      html  css  js  c++  java
  • C# WPF 路由命令

    下面是一个简单的投影转换小工具

    通过路由命令实现在所有参数都正确输入的情况下,"确定" 按钮可用

    // 定义与绑定路由命令 OkButton对象就是确定按钮
    RoutedCommand OkButtonCommand = new RoutedCommand("ReprojectRaster", typeof(MainWindow));
    OkButton.Command = OkButtonCommand;
    CommandBinding commandBinding = new CommandBinding();
    commandBinding.Command = OkButtonCommand;
    commandBinding.CanExecute += OkButtonCommandBinding_CanExecute;
    commandBinding.Executed += OkButtonCommandBinding_Executed; ;
    this.CommandBindings.Add(commandBinding);
    
    // 监听OkButton状态
    private void OkButtonCommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
    {
        // 添加一系列条件代码
        if ........
        else if ........
     
        e.CanExecute = false; // OkButton显示为不可用转态
        e.CanExecute = true; // OkButton显示为可用转态
    }
    
    // 执行OkButton点击的功能
    private void OkButtonCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
    {
       // 一系列数据处理代码
       ....
       e.Handled = true;
    }
    
  • 相关阅读:
    坦克大战
    java多线程应用场景
    java中的多线程(资料)
    设置线程名
    线程名称的设置及取得
    java调试
    文件上传细节处理
    Servlet生命周期
    java的动态绑定与静态绑定
    Mysql 连接池调用完成后close代理方法引出的设计模式
  • 原文地址:https://www.cnblogs.com/lqqgis/p/12649931.html
Copyright © 2011-2022 走看看