Demond
Topic Author
Posts: 20
Joined: 06 Feb 2023, 23:32

[noesis:MoveFocusAction] Direction="Down" doesn't work properly with KeyboardNavigation.TabNavigation="Cycle"

11 Mar 2025, 09:25

Hi! I found that the focus with Direction="Down" does not shift from the last element to the first when KeyboardNavigation.TabNavigation="Cycle" is enabled.
With Direction="Up" this problem does not occur, the focus moves smoothly from the first element to the last.

Here is a minimal example to reproduce this problem:
<Page x:Name="Test" 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:system="clr-namespace:System;assembly=mscorlib"
      xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions">

  <StackPanel Orientation="Horizontal">
    <ListView x:Name="TheListView1" SelectionMode="Single" KeyboardNavigation.TabNavigation="Cycle">
      <b:Interaction.Triggers>
        <b:KeyTrigger Key="D1">
          <noesis:MoveFocusAction Direction="Down" />
        </b:KeyTrigger>
      </b:Interaction.Triggers>
      <ListViewItem>Element 1</ListViewItem>
      <ListViewItem>Element 2</ListViewItem>
      <ListViewItem>Element 3</ListViewItem>
      <ListViewItem>Element 4</ListViewItem>
    </ListView>
  </StackPanel>
</Page>
 
User avatar
sfernandez
Site Admin
Posts: 3364
Joined: 22 Dec 2011, 19:20

Re: [noesis:MoveFocusAction] Direction="Down" doesn't work properly with KeyboardNavigation.TabNavigation="Cycle"

11 Mar 2025, 21:12

Directional navigation is configured by the KeyboardNavigation.DirectionalNavigation property, so you have to set that first.
And the second problem is that your ListView is focusable, so it is focusing it after reaching the top or the bottom of the list.

Could you please try the following instead:
<ListView x:Name="TheListView1" SelectionMode="Single" KeyboardNavigation.DirectionalNavigation="Cycle" Focusable="False">

Who is online

Users browsing this forum: schragnasher and 4 guests