zoukankan      html  css  js  c++  java
  • dev gridcontrol把event事件转换成命令

        可以通过继承gridcontrol的形式来实现 定义DataGridDoubleClickCommand依赖属性

    class MyGridControl : GridControl
        {

            public ICommand DataGridDoubleClickCommand
            {
                get { return (ICommand)GetValue(DataGridDoubleClickProperty); }
                set { SetValue(DataGridDoubleClickProperty, value); }
            }
            public static readonly DependencyProperty DataGridDoubleClickProperty =
        DependencyProperty.RegisterAttached("DataGridDoubleClickCommand", typeof(ICommand), typeof(MyGridControl),
                          new UIPropertyMetadata());

            public MyGridControl()
            {
                Loaded += MyGridControl_Loaded;
                this.MouseDoubleClick += MyGridControl_MouseDoubleClick;
            }

            void MyGridControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
            {
                if (DataGridDoubleClickCommand != null)
                {
                    DataGridDoubleClickCommand.Execute(null);
                }
            }

            private void MyGridControl_Loaded(object sender, System.Windows.RoutedEventArgs e) //这段代码为了自适应屏幕
            {
                var tableView = View as TableView;
                tableView.BestFitColumns();
                double actualGridWidth = tableView.IndicatorHeaderWidth + System.Windows.Forms.SystemInformation.VerticalScrollBarWidth;
                IList<DevExpress.Xpf.Grid.GridColumn> gcList = tableView.VisibleColumns;
                foreach (DevExpress.Xpf.Grid.GridColumn gc in gcList)
                {
                    actualGridWidth += gc.ActualAdditionalRowDataWidth;
                }
                double blankArea = tableView.ActualWidth - actualGridWidth;
                if (blankArea > 0)
                {
                    foreach (DevExpress.Xpf.Grid.GridColumn gc in gcList)
                    {
                        gc.Width = gc.ActualWidth + blankArea / gcList.Count;
                    }
                }

                tableView.ShowGroupPanel = false;
                tableView.AllowEditing = false;
            }
        }

  • 相关阅读:
    ES5 创建构造函数的私有属性
    js 触发打印操作
    创建 React 项目
    处理因使用 BigInt 等最新语法时 ts 编译报错
    TS 查找第三方声明文件
    Git 撤销工作区中的变动
    Git 查看文件修改状态
    Git 查看用户名和 Email
    查看某个 npm 包的所有发行版版本号,比如 vue
    Git 查看文件修改详情
  • 原文地址:https://www.cnblogs.com/tianmochou/p/6183075.html
Copyright © 2011-2022 走看看