开发者论坛

 找回密码
 注册 (请使用非IE浏览器)
查看: 1992|回复: 0

WPF DevExpress表格行双击事件转命令

[复制链接]

0

精华

2

贡献

0

赞扬

帖子
6
软币
72
在线时间
2 小时
注册时间
2018-6-1
发表于 2018-6-19 15:23:19 | 显示全部楼层 |阅读模式
<dxg:TableView
                            x:Name="viewDetail"
                            NavigationStyle="Cell"
                            RowIndicatorContentTemplate="{DynamicResource RowIndicatorContentTemplate}"
                            ShowCheckBoxSelectorColumn="True"
                            Style="{DynamicResource TableViewStyle}">
                            <i:Interaction.Behaviors>
                                <bh:BestFitColumnsBehavior />
                            </i:Interaction.Behaviors>
                            <dxmvvm:Interaction.Behaviors>
                                <dxmvvm:EventToCommand
                                    Command="{Binding WithdrawEntrustCommand}"
                                    EventArgsConverter="{inf:EventArgsToDataRowConverter}"
                                    EventName="MouseDoubleClick"
                                    PassEventArgsToCommand="True"
                                    SourceName="gridDetail" />
                            </dxmvvm:Interaction.Behaviors>
                        </dxg:TableView>

public class EventArgsToDataRowConverter : InstanceMarkupExtension<EventArgsToDataRowConverter>, IEventArgsConverter
    {
        public object Convert(object sender, object args)
        {
            var e = (MouseButtonEventArgs)args;
            var gridControl = (GridControl)e.Source;
            var rowControl = VisualHelper.FindVisualParent<RowControl>(e.OriginalSource as DependencyObject);
            var checkEdit = VisualHelper.FindVisualParent<CheckEdit>(e.OriginalSource as DependencyObject);
            //屏蔽双击CheckBox或者双击鼠标右键响应双击事件
            if (checkEdit != null || rowControl == null || e.ChangedButton != MouseButton.Left)
            {
                return null;
            }
            else
            {
                return gridControl.SelectedItem;
            }
        }

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return this;
        }
    }
仅供参考哦

回复

使用道具 举报

Archiver|手机版|小黑屋|开发者网 ( 苏ICP备08004430号-2 )
版权所有:南京韵文教育信息咨询有限公司

GMT+8, 2024-4-25 22:51

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表