0

i need to create below mention code at runtime in Wpf i.e. create AutoCompleteBox dynamically set size, width, location etc dynamically. Then set TabIndex dynamically. How to do this.

                <ToolKit:AutoCompleteBox Canvas.Left="227" Canvas.Top="845"  Name="txtFirstName" FontSize="15" Height="30" 
                                         TabIndex="4" Width="100" PreviewTextInput="txtFirstName_PreviewTextInput" >
                    <ToolKit:AutoCompleteBox.TextBoxStyle>
                        <Style TargetType="TextBox">
                            <Setter Property="TabIndex" Value="{Binding ElementName=txtFirstName, Path=TabIndex}"></Setter>
                        </Style>
                    </ToolKit:AutoCompleteBox.TextBoxStyle>
                </ToolKit:AutoCompleteBox>
Shashank
  • 6,117
  • 20
  • 51
  • 72
  • If you want to set the TabIndex dynamically, who (what class) is smart enough to calculate what the tab index should be? Someone has to be responsible for this. Once you have a class to handle this, the binding is easy. – Josh G Jun 22 '11 at 12:19

1 Answers1

0

If you leave all of the TabIndexes unset in your UserControl / Window, WPF will tab through them in left-to-right, top-to-bottom order. Usually I find that this is exactly what I want anyway so I seldom explicitly set the TabIndex property at all.

Josh G
  • 14,068
  • 7
  • 62
  • 74
  • In my case, I have observed that tab index will not work reason being. this AutoCompleteBox is present in WPFToolkit that can be downloaded from codeplex. And this itself doesn't gives tab indexing functionality – Shantanu Gupta Jun 22 '11 at 12:15