So my suggestion for you is this:
<DataGrid x:Name="DocumentTemplatesGrid" Grid.Row="2" ItemsSource="{Binding Items}" IsReadOnly="True" AutoGenerateColumns="False" SelectionMode="Single" SelectionUnit="FullRow" TabIndex="1" IsTabStop="True" PreviewKeyDown="DocumentTemplatesGrid_PreviewKeyDown"> <DataGrid.CellStyle> <Style TargetType="DataGridCell"> <Setter Property="IsTabStop" Value="False"/> <Setter Property="BorderThickness" Value="0"/> <Setter Property="FocusVisualStyle" Value="{x:Null}"/> </Style> </DataGrid.CellStyle> <DataGrid.RowStyle> <Style TargetType="DataGridRow"> <Setter Property="IsTabStop" Value="False"/> </Style> </DataGrid.RowStyle>
I added the PreviewKeyDown event to the DataGrid, and I removed the cell selection from each cell. As a result, it will appear that the selection is performed only in a row.
In the code behind, it opens links using Space / Enter:
private void DocumentTemplatesGrid_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == System.Windows.Input.Key.Space || e.Key == System.Windows.Input.Key.Enter) { if (e.Source is DataGrid) { string navigationUri = ((e.Source as DataGrid).SelectedItem as Class).Name; Process.Start(navigationUri); } e.Handled = true; } }
Hope this is what you are looking for, or at least some help.
source share