https://docs.devexpress.com/WPF/7875/index
Xaml:
<DataGrid ItemsSource="{Binding SessionList}"
Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="2"
AutoGenerateColumns="False"
ScrollViewer.CanContentScroll="False"
IsReadOnly="True"
HorizontalScrollBarVisibility="Auto"
SelectionMode="Single"
VerticalScrollBarVisibility="Auto"
MouseDoubleClick="datagrid_MouseDoubleClick"
CanUserAddRows="True"/>
cs代码:
private void datagrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
DataGrid datagrid = sender as DataGrid;
Point aP = e.GetPosition(datagrid);
IInputElement obj = datagrid.InputHitTest(aP);
DependencyObject target = obj as DependencyObject;
while (target != null)
{
if (target is DataGridRow)
{
break;
}
target = VisualTreeHelper.GetParent(target);
}
}
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick" >
<i:InvokeCommandAction Command="{Binding DataGridEditCommand}" CommandParameter="{ Binding ElementName=dataGrid1, Path=SelectedItem}" />
</i:EventTrigger>
</i:Interaction.Triggers>