I created the following view
<ListView.View>
<GridView>
<GridViewColumn Header="Tester"
DisplayMemberBinding="{Binding User}" />
<GridViewColumn Header="Executed On"
DisplayMemberBinding="{Binding ExecutionDate}" />
<GridViewColumn Header="Comment">
<GridViewColumn.CellTemplate>
<DataTemplate>
<DockPanel>
<TextBox Text="{Binding Comment}" Name="TxtComment"
MinWidth="100" VerticalContentAlignment="Top"
BorderThickness="0" PreviewKeyDown="TxtComment_PreviewKeyDown"/>
</DockPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
Now what I suppose is that, After I entered something in "Comment" field and press the Key "Enter", the next row of the "Comment" field will get focus.
I added the following code of the event "PreviewKeyDown", but it seems that the next whole row will get focus not only the "Comment" field...
Private Sub TxtComment_PreviewKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Input.KeyEventArgs)
Dim focusRequest As TraversalRequest
Dim focusedElement As Object = sender
Select Case e.Key
Case Key.Enter
focusRequest = New TraversalRequest(FocusNavigationDirection.Down)
Case Else
' Do nothing
Return
End Select
' Do not further propagate event
e.Handled = True
'Move focus
DirectCast(focusedElement, UIElement).MoveFocus(focusRequest)
End Sub
Hope someone can tell me how to solve this problem, ^0^