aKzenT
aKzenT

Reputation: 7895

How to set focusable in a UserControl correctly?

what is the correct value for the Focusable property in a UserControl in case you have a single Control (e.g. TextBox) wrapped inside?

All examples I have seen were about the case where you have multiple Controls wrapped inside a UserControl.

Obviously I want to have the TextBox have the focus, but not the UserControl itself. How do I set the Focusable correctly and what more do I have to consider in this case?

Thanks!

Upvotes: 1

Views: 318

Answers (1)

Rachel
Rachel

Reputation: 132558

If I understand you correctly, you want to know the correct way to tell WPF that it shouldn't allow focus to go to a UserControl.

For example, if you tab through a UserControl containing a TextBox, it will cycle between the UserControl itself and the TextBox control inside of it, instead of just tabbing to the TextBox

To prevent the UserControl from gaining focus like this you would set the IsTabStop property to False

<UserControl IsTabStop="False" ... />

Upvotes: 1

Related Questions