我有一个简单的TreeView,无法在具有焦点的TextBox中导航。你有什么建议吗???

我已经更新了xaml代码,以便为您提供更多详细信息。我希望这是有帮助的。
更多详情。
更多详情。
更多详情。
更多详情。
更多详情。

<StackPanel Orientation="Vertical" Margin="5">
    <StackPanel Orientation="Vertical">
                    <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" SharedSizeGroup="Column1"/>
                <ColumnDefinition Width="5"    SharedSizeGroup="Column2"/>
                <ColumnDefinition Width="*"   />
            </Grid.ColumnDefinitions>

            <Grid.RowDefinitions>
                <RowDefinition Height="28"/>
                <RowDefinition Height="28"/>
            </Grid.RowDefinitions>

            <GridSplitter Grid.Column="1" Grid.RowSpan="2147483647" HorizontalAlignment="Left" Width="5" VerticalContentAlignment="Stretch" IsTabStop="False"/>

            <TextBlock Name="Number" Grid.Row="0" Grid.Column="0" Text="Number"/>
            <TextBox x:Name="TxtNumber" Grid.Row="0" Grid.Column="2" Text="{Binding Number}" TabIndex="0"/>

            <TextBlock Name="Name" Grid.Row="1" Grid.Column="0" Text="Name"/>
            <TextBox Grid.Row="1" Grid.Column="2" Text="{Binding Name}" TabIndex="1"/>
        </Grid>
    </StackPanel>

    <StackPanel Orientation="Vertical">
        <TextBlock Text="MyTree"/>

        <TreeView x:Name="MyTree" BorderThickness="0" Grid.IsSharedSizeScope="True" KeyboardNavigation.TabNavigation="Continue">
            <TreeView.Resources>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" />
                <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="Transparent" />
                <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}" Color="Black" />
            </TreeView.Resources>

            <TreeView.ItemContainerStyle>
                <Style TargetType="{x:Type TreeViewItem}">
                    <Setter Property="IsExpanded" Value="True" />
                    <Setter Property="KeyboardNavigation.TabNavigation" Value="Continue"/>
                </Style>
            </TreeView.ItemContainerStyle>

            <TreeViewItem>
                <TreeViewItem.Header>
                    <TextBlock Text="First Block" FontWeight="Bold"/>
                </TreeViewItem.Header>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" SharedSizeGroup="Column1"/>
                        <ColumnDefinition Width="5"    SharedSizeGroup="Column2"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <Grid.RowDefinitions>
                        <RowDefinition Height="28"/>
                        <RowDefinition Height="28"/>
                        <RowDefinition Height="28"/>
                        <RowDefinition Height="28"/>
                    </Grid.RowDefinitions>

                    <GridSplitter Grid.Column="1" Grid.RowSpan="4" Width="5" HorizontalAlignment="Left" VerticalContentAlignment="Stretch" IsTabStop="False"/>

                    <TextBlock Grid.Row="0" Grid.Column="0" Text="A"/>
                    <CheckBox Grid.Row="0" Grid.Column="2" IsChecked="{Binding A}"/>

                    <TextBlock Grid.Row="1" Grid.Column="0" Text="B"/>
                    <TextBox Grid.Row="1" Grid.Column="2" Text="{Binding B}" Width="200"/>

                    <TextBlock Name="PassBin" Grid.Row="2" Grid.Column="0" Text="C"/>
                    <ComboBox x:Name="CbxPassBin" Grid.Row="2" Grid.Column="2" ItemsSource="{Binding C}" SelectedValue="{Binding SelectedC}"/>
                </Grid>
            </TreeViewItem>
        </TreeView>
    </StackPanel>
</StackPanel>

最佳答案

TabIndex应该是1Focusable="true"

关于c# - TreeViewItem元素中的C#标签索引,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30886992/

10-09 21:46