views:

456

answers:

2

I want to be able to route the double-click of a grid to a Command. I'm using Rx to simulate the double click but I can't figure out what control to attach the mouse handler to (the mouse event on the e.Row object in DataGrid.RowLoading event doesn't seem to work).

Anyone got any ideas?

Rx code for handling the Double click is as follows:

Observable.FromEvent<MouseButtonEventArgs>(e.Row, "MouseLeftButtonDown").TimeInterval().Subscribe(evt =>
        {
            if (evt.Interval.Milliseconds <= 300)
            {
                // Execute command on double click
            }
        });
+1  A: 

I changed this code from handling MouseLeftButtonDown to MouseLeftButtonUp and it works now. The row must have something else handling the button down events.

Observable.FromEvent<MouseButtonEventArgs>(e.Row, "MouseLeftButtonUp").TimeInterval().Subscribe(evt => 
    { 
        if (evt.Interval != TimeSpan.Zero && evt.Interval.TotalMilliseconds <= 300) 
        { 
            // Execute command on double click 
        } 
    }); 
Flatliner DOA
A: 

I'm having similar problems (though not using Rx to handle the double click, instead using a generic DoubleClickTrigger). My specific problem is more related to the fact that I'm not sure how or where to hook up my trigger. I've tried something like the following:

                    <data:DataGrid.Resources>
                        <ControlTemplate x:Key="rowTemplate" TargetType="data:DataGridRow">
                            <data:DataGridRow>
                                <fxui:Interaction.Triggers>
                                    <fxui:DoubleClickTrigger>
                                        <Interactivity:InvokeCommandAction Command="{Binding Source={StaticResource selectCommand}}" CommandParameter="{Binding}"/>
                                    </fxui:DoubleClickTrigger>
                                </fxui:Interaction.Triggers>
                            </data:DataGridRow>
                        </ControlTemplate>
                    </data:DataGrid.Resources>
                    <data:DataGrid.RowStyle>
                        <Style TargetType="data:DataGridRow">
                            <Setter Property="Template" Value="{StaticResource rowTemplate}"/>
                        </Style>

                    </data:DataGrid.RowStyle>

With no luck.

Jimit