0

I need the TabNavigation to Traverse the entire VisualTree .

Iv'e get a custom control in a view which i need it's inner elements to take part in the View's TabNavigation.

I need to use TabIndex in my view since i need the tab flow to be top to bottom

Custom control's Template :

   <ControlTemplate>

        <Grid>
           <TextBox x:Name="first"/>
           <TextBox /> 
           <TextBox /> 
        </Grid>

        <ControlTemplate.Triggers>
          <Trigger Property="IsFocused" Value="True">
              <Setter TargetName="first" Property="FocusManager.FocusedElement" Value="{Binding ElementName=first}" />
          </Trigger>
        </ControlTemplate.Triggers>
  </ControlTemplate>

View :

        <Grid>
            <Grid.ColumnDefentions>
                <ColumnDefention />
                <ColumnDefention /> 
            </Grid.ColumnDefentions>


            <TextBox Grid.Column="0" TabIndex="0" />
            <local:MyControl Grid.Column="0" TabIndex="1" /> 
            <TextBox Grid.Column="0" TabIndex="2" />

            <TextBox Grid.Column="1" TabIndex="3" />
            <TextBox Grid.Column="1" TabIndex="4" />
            <TextBox Grid.Column="1" TabIndex="5" />

        </Grid>

when navigating TabIndex 0 in navigated to , then the first textbox in my control and then second and third ,TabIndex 2 IS NOT navigated to , it is as if it lost the tab index.

how can i incorporate the navigation inside a custom control's template in the tab flow of the entire view ?

Charles
  • 50,943
  • 13
  • 104
  • 142
eran otzap
  • 12,293
  • 20
  • 84
  • 139

1 Answers1

0

Given the same TabIndex as their parent , the items in the parent's visual tree get tabbed in order.

<ControlTemplate>

    <Grid>
       <TextBox TabIndex={TempalteBinding TabIndex} />
       <TextBox TabIndex={TempalteBinding TabIndex} /> 
       <TextBox TabIndex={TempalteBinding TabIndex} /> 
    </Grid>
<ControlTemplate>

View :

  <Grid>
        <Grid.ColumnDefentions>
            <ColumnDefention />
            <ColumnDefention /> 
        </Grid.ColumnDefentions>


        <TextBox Grid.Column="0" TabIndex="0" />
        <local:MyControl Grid.Column="0" TabIndex="1" IsTabStop="False" /> 
        <TextBox Grid.Column="0" TabIndex="2" />

        <TextBox Grid.Column="1" TabIndex="3" />
        <TextBox Grid.Column="1" TabIndex="4" />
        <TextBox Grid.Column="1" TabIndex="5" />

    </Grid>
eran otzap
  • 12,293
  • 20
  • 84
  • 139