WPF TabIndex 无法正常工作
WPF TabIndex doesn't work correctly
我在正确设置 TabIndexes
时遇到问题。我有一个 Usercontrol
和一个 GroupBox
.
<GroupBox KeyboardNavigation.TabNavigation="Local" TabIndex="0">
<Grid KeyboardNavigation.TabNavigation="Continue">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0" KeyboardNavigation.TabNavigation="Continue">
<my:uscZeitraum TabIndex="1" />
<Label />
<ComboBox TabIndex="2" />
<Label />
<ComboBox TabIndex="3" HorizontalAlignment="Right" VerticalAlignment="Top" Width="88" />
<Label />
<ComboBox TabIndex="4" HorizontalAlignment="Right" VerticalAlignment="Top" Width="67" />
<Label />
<ComboBox TabIndex="5" IsEditable="True" GotFocus="cboVorgang_GotFocus" HorizontalAlignment="Right" VerticalAlignment="Top" Width="93" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="1" KeyboardNavigation.TabNavigation="Continue">
<Label />
<ComboBox TabIndex="6" HorizontalAlignment="Left" Width="192" Height="23" VerticalAlignment="Bottom" />
<Label />
<ComboBox TabIndex="7" Height="23" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="225" />
<Label />
<ComboBox IsEditable="True" TabIndex="8" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="67" />
<Label />
<ComboBox IsEditable="True" TabIndex="9" Width="80" />
</StackPanel>
</Grid>
</GroupBox>
第一个 Control
也是一个 UserControl
但这就像我想要的那样。但是,如果我在第一个 StackPanel
中到达第三个 ComboBox
,它就会再次从头开始。它不会关注第四个 ComboBox
,也不会跳转到第二个 Row
/Stackpanel
。那会是什么?
cboVorgang_GotFocus 中一定有一些代码正在执行此操作。那里编写的代码会更改 Tab 键顺序。
我在正确设置 TabIndexes
时遇到问题。我有一个 Usercontrol
和一个 GroupBox
.
<GroupBox KeyboardNavigation.TabNavigation="Local" TabIndex="0">
<Grid KeyboardNavigation.TabNavigation="Continue">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0" KeyboardNavigation.TabNavigation="Continue">
<my:uscZeitraum TabIndex="1" />
<Label />
<ComboBox TabIndex="2" />
<Label />
<ComboBox TabIndex="3" HorizontalAlignment="Right" VerticalAlignment="Top" Width="88" />
<Label />
<ComboBox TabIndex="4" HorizontalAlignment="Right" VerticalAlignment="Top" Width="67" />
<Label />
<ComboBox TabIndex="5" IsEditable="True" GotFocus="cboVorgang_GotFocus" HorizontalAlignment="Right" VerticalAlignment="Top" Width="93" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="1" KeyboardNavigation.TabNavigation="Continue">
<Label />
<ComboBox TabIndex="6" HorizontalAlignment="Left" Width="192" Height="23" VerticalAlignment="Bottom" />
<Label />
<ComboBox TabIndex="7" Height="23" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="225" />
<Label />
<ComboBox IsEditable="True" TabIndex="8" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="67" />
<Label />
<ComboBox IsEditable="True" TabIndex="9" Width="80" />
</StackPanel>
</Grid>
</GroupBox>
第一个 Control
也是一个 UserControl
但这就像我想要的那样。但是,如果我在第一个 StackPanel
中到达第三个 ComboBox
,它就会再次从头开始。它不会关注第四个 ComboBox
,也不会跳转到第二个 Row
/Stackpanel
。那会是什么?
cboVorgang_GotFocus 中一定有一些代码正在执行此操作。那里编写的代码会更改 Tab 键顺序。