Ticket T1279257
Visible to All Users

Grid - detect which column I am doubleclicking in.

created a day ago

I have a row doubleclick defined like this in my XAML (using the MVVM Community Toolkit). I need to make an exception, if the user double clicks in the first column (fieldname is IsSelected), i want to use some different logic. I can't figure out how to tell which column was focused in my event.

Is the correct answer to implement CellDoubleClick instead of Row for every column? That would be very tedious. I have full access to the grid through my GridService, I just don't know how to check.

XAML
<dxg:TableView ShowGroupPanel="False" ShowIndicator="False" FadeSelectionOnLostFocus="False" EnableImmediatePosting="True" RowDoubleClickCommand="{Binding GridRowDoubleClickedCommand, Converter={dxmvvm:ToTypedCommandConverter}}" />
C#
[RelayCommand] private void OnGridRowDoubleClicked( DevExpress.Mvvm.Xpf.RowClickArgs e ) { var focusedRow = GridSupportService.FocusedRowGet<DataSourceSelectorRowViewModel>();

Answers approved by DevExpress Support

created a day ago

Hello Greg,

At first glance, the RowDoubleClickCommand is not the most suitable solution for this task. While workarounds are possible, the RowDoubleClick event arguments contain the required hit information out of the box. You can use the following property to get the column name:

Code
e.HitInfo.Column.FieldName

You can use our EventToCommand behavior to process a UI event at the view model level.


As an alternative to EventToCommand, you can use our DXEvent extension to simplify the implementation. For example:

XAML
<dxg:TableView RowDoubleClick="{DXEvent Handler='RowDoubleClickHandler(@args.HitInfo.Column.FieldName)'}" />

I attached a simple sample that demonstrates this solution.

Let me know if this helps.

Regards,
Alexander

    Comments (2)
    GR GR
    Greg Robertson a day ago

      Thanks for the quick response, I'll try this out.

      Alexander D (DevExpress Support) a day ago

        You are always welcome, Greg.
        Alexander

        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.