我有一个带有Grid的UserControl,它包含一个简单的TreeView。我能够向前导航(Tab),而向后方向(Alt + Tab)不能正常工作。 (它关注我的项目模板中的最后一个按钮)。 你有什么建议吗?
<TreeView ItemsSource="{Binding myList}"
KeyboardNavigation.TabNavigation="Continue" TabIndex="4" IsTabStop="False">
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="True" />
<Setter Property="KeyboardNavigation.TabNavigation" Value="Continue"/>
</Style>
</TreeView.ItemContainerStyle>
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding MySubList}">
<TextBlock Text="{Binding Name}" FontWeight="Bold"/>
<HierarchicalDataTemplate.ItemTemplate>
<HierarchicalDataTemplate>
<Grid KeyboardNavigation.TabNavigation="Local">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="Col1"/>
<ColumnDefinition Width="5" SharedSizeGroup="Col2"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<GridSplitter Grid.Column="1" Grid.RowSpan="2147483647" Width="5" HorizontalAlignment="Left" VerticalContentAlignment="Stretch" IsTabStop="False"/>
<TextBlock Grid.Column="0" Grid.Row="0" Text="Text1"/>
<TextBox Grid.Column="2" Grid.Row="0" Text="{Binding Text1, UpdateSourceTrigger=LostFocus}" TabIndex="0"/>
<Button Grid.Column="3" Grid.Row="0" Content="..." TabIndex="1"/>
</Grid>
</HierarchicalDataTemplate>
</HierarchicalDataTemplate.ItemTemplate>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>