Need to move tab focus to the popup element

asked 2020-05-15T04:13:34.353+00:00
Magesh Sankar 36 Reputation points

I have custom control, in which i need to provide keyboard navigation support for all elemenst used in it, but I have failed to move tab focus to popup element on button click. Please find the code for reproducing.I have used move focus method to navigate focus

</Button>
<Popup x:Name="popup" Placement="Bottom" Focusable="True" PlacementTarget="{Binding ElementName=button}">
<DockPanel Focusable="True">
<ToggleButton Focusable="True" >button1</ToggleButton>
<ToggleButton Focusable="True">button1</ToggleButton>
<ToggleButton Focusable="True">button1</ToggleButton>
</DockPanel>

        </Popup>  

Please suggest solution to move focus to popup element on button click.

Thanks,

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,171 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. answered 2020-05-18T02:27:09.077+00:00
    Alex Li-MSFT 1,081 Reputation points

    Welcome to our Microsoft Q&A platform!

    In WPF, the element that has keyboard focus will have IsKeyboardFocused set to true. The default value of Popup.IsKeyboardFocused is false and read only property, so you can't get focus on the popup. You could use Keyboard.Focus(targetedElement) in the event to make it to be focused. You can refer to document Keyboard Focus and sample in the thread: WPF Popup tab key bug for more info.
    Keyboard Focus

    Thanks.

    No comments