Demir
Demir

Reputation: 1837

Enable Tab Stop for TextBox in a UserControl exists in StackPanel

I have a user control that consists of a CheckBox and a TextBox. I create instances of this user control dynamically at runtime according to properties of my object and add them into a StackPanel.

I would like to enable Tab navigation between these TextBoxes. Setting IsTabStop="True" for the TextBox in the user control did not worked. I have also set KeyboardNavigation.TabNavigation="Contained" for TextBox but not succeeded.

Upvotes: 1

Views: 1770

Answers (1)

Demir
Demir

Reputation: 1837

I found the solution:

Set KeyBoardNavigation property of the container not the TextBox. I do this in code behind because I create my StackPanel instances dynamically.

MyStackPanel.IsTabStop = true;    
MyStackPanel.SetValue(KeyboardNavigation.TabNavigationProperty, KeyboardNavigationMode.Cycle);

Also make sure TextBox has IsTabStop property set True:

KeyboardNavigation.IsTabStop="True"

Upvotes: 1

Related Questions