将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事件绑定
发布评论