I have a Window
with few controls on it. One of them is a DataGrid
. I want to implement some non-default focus traversal. Namely:
DataGrid
is a single stop as a whole, not each row.- When
DataGrid
is focused, user can navigate through rows using up and down keys. - Navigating through columns using left and right keys is not allowed.
- First column (and the only relevant for navigation) is of type
DataGridHyperlinkColumn
. When user hits Space or Enter key, it executes the hyperlink.
At the moment I have the following code:
<DataGrid x:Name="DocumentTemplatesGrid"
Grid.Row="2"
ItemsSource="{Binding Source={StaticResource DocumentTemplatesView}}"
IsReadOnly="True"
AutoGenerateColumns="False"
SelectionUnit="FullRow"
SelectionMode="Single"
TabIndex="1"
IsTabStop="True">
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="IsTabStop" Value="False"/>
</Style>
</DataGrid.CellStyle>
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Setter Property="IsTabStop" Value="False"/>
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridHyperlinkColumn Header="Name"
Width="2*"
Binding="{Binding Name}"/>
<DataGridTextColumn Header="Description"
Width="5*"
Binding="{Binding Description}"/>
<DataGridTextColumn Header="Type"
Width="*"
Binding="{Binding Type}"/>
</DataGrid.Columns>
</DataGrid>
Unfortunately, it does not reach my expectations. Could you, please, explain how to achieve this?