开发者

DataGridTextColumn event binding

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?

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

<dg:DataGridTextColumn Header="Numbe开发者_如何学JAVAr" Binding="{Binding BusinessId}" 
                                   Width="75" IsReadOnly="True" CanUserReorder="False" 
                                   />

Cheers,

Berryl


the short answer is no.

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

  • derive from the grid and override the preview onmousedoubleclick method

or

  • put an event handler in the code behind of the form hosting the grid

then

  • calculate which cell was double clicked on

  • get its parent column.

  • 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜