question

MageshSankar-9134 avatar image
0 Votes"
MageshSankar-9134 asked ·

Need to move tab focus to the popup element




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-wpf
10 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AlexLi-MSFT avatar image
0 Votes"
AlexLi-MSFT answered ·

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.

10 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.