views:

135

answers:

1

Hello, I'm trying to setup the tab keyboard control options on my current WPF project in xaml.

Essentially, I've got a TextBox element within a view, within another view, within another view. Anyway, when pushing tab on the keyboard, it starts cycling through various elements of the container views and eventually goes to the TextBox I need it to go to. I'm hoping to make it start at this text box, and I'm hoping there is an easy way to accomplish this.

I tried setting KeyboardBinding.TabNavigation settings, as well as TabIndex options, but these aren't working in the way I'm trying to get.

From what I understand so far, I'm worried I may need to go to the container views and set up a binding property on each of the ItemControls individually and then it would use the local tabbing settings for each child element.

Anyway, I'm hoping there is a more efficient way.

Thanks in advance.

+2  A: 

At your root container (in my example it's a user control) set the focus like this:

<UserControl FocusManager.FocusedElement="{Binding ElementName=txtMyTextBox}">
    <TextBox x:Name="txtMyTextBox" />
</UserControl>
Micah
Excellent! That's exactly what I needed! Thank you! :)
AnujSuper9
No sweat. Glad I could help.
Micah