views:

125

answers:

1

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="Number" Binding="{Binding BusinessId}" 
                                   Width="75" IsReadOnly="True" CanUserReorder="False" 
                                   />

Cheers,
Berryl

A: 

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.

Aran Mulholland