2010-10-15 5 views
1

J'ai une fenêtre/formulaire WPF avec diverses commandes.WPF Tabindexes ne se comporte pas comme prévu - La force est faible

J'ai mis les tabindexes dans l'ordre désiré, mais j'ai un comportement étrange. Lorsque l'on parcourt la fenêtre, l'ordre doit être le suivant: les premières zones de texte à gauche, puis les contrôles de date à droite, puis mon onglet et les pages à onglets, puis seulement les boutons.

Mais le contrôle onglet est ignoré et la mise au point se déplace directement vers les boutons. Si je continue à tabuler après les boutons, le contrôle onglet est alors sélectionné.

Ci-dessous est le xmal.

Toute aide est appréciée.

<Window xmlns:my="clr-namespace:DevExpress.Xpf.Editors;assembly=DevExpress.Xpf.Core.v10.1" x:Class="TabStopIssue.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" 
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" 
     Title="MainWindow" Height="350" Width="525"> 
    <Grid> 
    <Grid > 
     <Grid.RowDefinitions> 
     <RowDefinition /> 
     <RowDefinition /> 
     <RowDefinition /> 
     </Grid.RowDefinitions> 
     <Grid Grid.Row="0"> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="2*"/> 
      <ColumnDefinition Width="2*"/> 
      <ColumnDefinition Width="3*" /> 
      <ColumnDefinition Width="3*"/> 
     </Grid.ColumnDefinitions> 
     <Grid.RowDefinitions> 
      <RowDefinition /> 
      <RowDefinition /> 
      <RowDefinition /> 
      <RowDefinition /> 
     </Grid.RowDefinitions> 


     <Label Grid.Row="1" Grid.Column="0" Content="Name"/> 
     <dxe:ComboBoxEdit Grid.Row="1" Grid.Column="1" Text="" TabIndex="0" /> 

     <Label Grid.Row="2" Grid.Column="0" Content="Description"/> 
     <dxe:TextEdit Grid.Row="2" Grid.Column="1" TabIndex="1" /> 

     <Label Grid.Row="1" Grid.Column="2" Content="From Date"/> 
     <dxe:DateEdit Grid.Row="1" Grid.Column="3" TabIndex="2" /> 

     <Label Grid.Row="2" Grid.Column="2" Content="ToDate"/> 
     <dxe:DateEdit Grid.Row="2" Grid.Column="3" TabIndex="3" /> 
     </Grid> 
     <Grid Grid.Row="1"> 
     <TabControl TabIndex="4"> 
      <TabItem Header="Tab1" TabIndex="5"> 
      <Grid > 
       <TextBox>Enter Text Here</TextBox> 
      </Grid> 
      </TabItem> 

      <TabItem Header="Tab2" TabIndex="6"> 
      <Grid > 
       <TextBox>Enter Text Here</TextBox> 
      </Grid> 
      </TabItem> 

      <TabItem Header="tab3" TabIndex="7"> 
      <Grid > 
       <TextBox>Enter Text Here</TextBox> 
      </Grid> 
      </TabItem> 

      <TabItem Header="tab4" TabIndex="8"> 
      <Grid > 
       <TextBox>Enter Text Here</TextBox> 
      </Grid> 
      </TabItem> 

      <TabItem Header="tab5" TabIndex="9"> 
      <Grid > 
       <TextBox>Enter Text Here</TextBox> 
      </Grid> 
      </TabItem> 
     </TabControl> 
     </Grid> 
     <Grid Grid.Row="2"> 
     <StackPanel HorizontalAlignment="Right"> 
      <Button Content="Button1" IsDefault="True" TabIndex="10" /> 
      <Button Content="Button2" TabIndex="11" /> 
      <Button Content="button3" IsCancel="True" TabIndex="12" /> 
     </StackPanel> 
     </Grid> 
    </Grid> 
    </Grid> 
</Window> 

Répondre

4

Pour obtenir TabControl apparaisse au bon endroit dans l'ordre de tabulation, modifier l'élément TabControl comme ceci:

<TabControl TabIndex="4" KeyboardNavigation.TabNavigation="Local"> 

Vous ne pouvez pas utiliser la touche de tabulation pour faire défiler les onglets individuels sur le TabControl autant que je sache. Le comportement des fenêtres standard consiste à utiliser les touches fléchées pour cela.

+0

Salut Samuel, Merci pour votre aide. Travaillé comme un charme. – SetiSeeker

Questions connexes