devexpress gridControl增加双击事件

增加定义:

        public ICommand<RowClickArgs> RowDoubleClickCommand { get; set; }

初始化:

备注:一定要放在构造函数里

        public MainWindow()
        {
            RowDoubleClickCommand = new DelegateCommand<RowClickArgs>(RowDoubleClick);
            InitializeComponent();
        }

定义方法:

        [Command]
        public void RowDoubleClick(RowClickArgs args)
        {
            DXMessageBox.Show("Row double click: " + ((ProjectInfo)args.Item).Name);
        }

前台使用:

增加“RowDoubleClickCommand="{Binding ElementName=testWindow,Path=RowDoubleClickCommand}"”,如下图:

            <dxg:GridControl.View>
                <dxg:TableView x:Name="tableView"
                               RowDoubleClickCommand="{Binding ElementName=testWindow,Path=RowDoubleClickCommand}"
                                   AllowEditing="False"
                                   LeftGroupAreaIndent="0"
                                   ShowSearchPanelMode="Never"
                                   SearchPanelNullText=""
                                   ShowGroupPanel="False"
                                   ShowIndicator="True"
                                   ShowVerticalLines="True"
                                   CompactPanelShowMode="Always"
                                   SwitchToCompactModeWidth="500"
                                   RowMinHeight="30"
                                   NavigationStyle="Row">
                    <dxg:TableView.RowCellMenuCustomizations>
                        <dxb:BarButtonItem Name="showFileInFolder"
                                           Content="查看文件"
                                           Command="{Binding ElementName=testWindow,Path=CommandShowFileInFolder}"
                                           CommandParameter="{Binding ElementName=testWindow, Path=CellMenuInfo.Row.RowHandle.Value}" />
                    </dxg:TableView.RowCellMenuCustomizations>
                </dxg:TableView>
            </dxg:GridControl.View>

 

posted @ 2021-10-18 17:44  星星c#  阅读(513)  评论(0编辑  收藏  举报