Ticket Q304725
Visible to All Users

Handle double click

created 14 years ago

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

Comments (1)

    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

    Answers approved by DevExpress Support

    created 14 years ago (modified 11 years ago)

    Hi Andrew,
    I apologize for the delay in responding.

    1. 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.
    2. 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

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.