Hello,
I need to handle double click in a grid cell.
I tried many approaches and none of them works.
Here is my take on it:
<dxg:GridColumn Header="Color" FieldName="Color" MouseUp="GridColumn_MouseUp">
<dxg:GridColumn.DisplayTemplate>
<ControlTemplate>
<TextBlock Background="{Binding EditValue, RelativeSource={RelativeSource TemplatedParent}}"/>
</ControlTemplate>
</dxg:GridColumn.DisplayTemplate>
<dxg:GridColumn.EditTemplate>
<ControlTemplate>
<Label MouseDoubleClick="Label_MouseDoubleClick"
Controls:MouseDoubleClick.Command="{Binding Path=Grid.DataContext.SelectColor}"
Controls:MouseDoubleClick.CommandParameter="{Binding Path=View.SelectedRows}"
Background="{Binding EditValue, RelativeSource={RelativeSource TemplatedParent}}"/>
</ControlTemplate>
</dxg:GridColumn.EditTemplate>
</dxg:GridColumn>
Neither GridColumn_MouseUp no Label_MouseDoubleClick is not invoked.
Thank you,
Andrew
Handle double click
Answers approved by DevExpress Support
Hi Andrew,
I apologize for the delay in responding.
- This problem appears because NavigationStyle is set to "Row", so the cell editor is not going to edit mode and the button is not shown.
- To accomplish this task I suggest that you use CellTemplates as shown below:
XAML<dxg:GridColumn.CellTemplate>
<DataTemplate>
<dxe:ButtonEdit x:Name="PART_Editor" Text="123" AllowDefaultButton="False">
<dxe:ButtonEdit.Buttons>
<dxe:ButtonInfo Command="{Binding Path=(dxg:GridControl.ActiveView).Grid.DataContext, RelativeSource={RelativeSource Self}}"/>
</dxe:ButtonEdit.Buttons>
</dxe:ButtonEdit>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
However, I should mention that this approach will work only starting from the version 2010.1 of DXGrid control.
Thanks,
Andrew
Hello,
It seems like I'm able to get it with XAML like this:
<dxg:GridControl.Columns>
<dxg:GridColumn Header="Color" FieldName="Color" MouseUp="GridColumn_MouseUp">
<dxg:GridColumn.DisplayTemplate>
<ControlTemplate>
<TextBlock Background="{Binding EditValue, RelativeSource={RelativeSource TemplatedParent}}"/>
</ControlTemplate>
</dxg:GridColumn.DisplayTemplate>
<dxg:GridColumn.EditTemplate>
<ControlTemplate>
<Editors:ButtonEdit IsTextEditable="False"
Background="{Binding EditValue, RelativeSource={RelativeSource TemplatedParent}}"
Name="PART_Editor"
Text="Change color"
AllowDefaultButton="False">
<Editors:ButtonInfo ClickMode="Release" Click="ButtonInfo_Click"
Command="{Binding Path=Grid.DataContext.SelectColor}"
GlyphKind="Regular"/>
</Editors:ButtonEdit>
</ControlTemplate>
</dxg:GridColumn.EditTemplate>
</dxg:GridColumn>
</dxg:GridControl.Columns>
I've got 2 questions:
1). Why does it stop showing a button in edit mode if I add this
<dxg:GridControl.View>
<dxg:TableView AllowSorting="False"
ShowFilterPanelMode="Default"
ShowGroupPanel="False"
MultiSelectMode="Row"
NavigationStyle="Row">
</dxg:TableView>
</dxg:GridControl.View>
?
2). Command="{Binding Path=Grid.DataContext.SelectColor}" doesn't work in Editors:ButtonInfo.
SelectColor is a property of type ICommand on my view model which I set to DataContext of a grid.
How can I refer to it to get it bound to Editors:ButtonInfo.Command?
Thank you,
Andrew