DataGridTextColumn事件绑定 [英] DataGridTextColumn event binding

查看:138
本文介绍了DataGridTextColumn事件绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将ICommand绑定到DataGridTextColumn的最简单的方法是什么,这将处理用户双击该列而不使用代码?我可以以某种方式暴露一个底层的FE,并在XAML中做到这一切吗?

What is the simplest way to bind an ICommand to a DataGridTextColumn that will handle a user double click on that column without code behind? Can I somehow expose an underlying FE and do it all in the XAML?

这个特定的列是只读的,这里是xaml:

This particular column is read only and here is the xaml for it:

<dg:DataGridTextColumn Header="Number" Binding="{Binding BusinessId}" 
                                   Width="75" IsReadOnly="True" CanUserReorder="False" 
                                   />

干杯,

Berryl

Cheers,
Berryl

推荐答案

简短的答案是否。

你不能在xaml的列上创建一个新的命令属性。在处理这个问题的过去,我:

you cant create a new command property on a column in xaml. In the past when dealing with this problem I:


  • 从列中派生并添加命令

  • derive from the column and add the command

从网格派生并覆盖预览onmousedoubleclick方法

derive from the grid and override the preview onmousedoubleclick method


  • 在托管网格的表单后面的代码中放置一个事件处理程序

然后


  • 计算哪个单元格被双击

  • calculate which cell was double clicked on

获取其父列。

如果它是带有extra命令属性的派生类型的列,请激活命令在列上,或者在派生网格上有命令,并发送列作为命令参数。

if it was a column of the derived type with the extra command property, fire the command on the column, or have the command on the derived grid and send the column as the command parameter.

这篇关于DataGridTextColumn事件绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆