Hi,
Welcome to our Microsoft Q&A platform!
We can continue to discuss this Thread.
why-mousedoubleclickeventtrigger-for-datagrid-works-only-once-on-each-row
I think there is something wrong with the parameters of your LabelPrintOutputListDoubleClicked method,you can see my Test method .
public class MyViewMode
{
public ICommand DoubleClickCommand { get; set; }
public MyViewMode()
{
DoubleClickCommand = new MyDelegateCommand();
(DoubleClickCommand as MyDelegateCommand).ExecuteCommand = Test;
(DoubleClickCommand as MyDelegateCommand).CanExecuteCommand = CanTest;
}
private void Test(object para)
{
MessageBox.Show(GetCellValue((DataGridCellInfo)para).ToString());
}
public object GetCellValue(DataGridCellInfo cellInfo)
{
if (cellInfo != null)
{
var column = cellInfo.Column as DataGridBoundColumn;
if (column != null)
{
var element = new FrameworkElement() { DataContext = cellInfo.Item };
BindingOperations.SetBinding(element, FrameworkElement.TagProperty, column.Binding);
var cellValue = element.Tag;
if (cellValue != null)
return (cellValue);
}
}
return (null);
}
private bool CanTest(object para)
{
return true;
}
}
MVVM Code:
<Grid>
<DataGrid Name="LabelPrintOutputDataList">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<i:InvokeCommandAction Command="{Binding DoubleClickCommand}" CommandParameter="{Binding ElementName=LabelPrintOutputDataList, Path=CurrentCell}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</DataGrid>
</Grid>
Thanks.