TreeViewItem元素中的C#Tab索引

时间:2015-06-17 09:04:10

标签: c# wpf xaml

我有一个简单的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>

2 个答案:

答案 0 :(得分:0)

TabIndex应为function redirect_to_profile() { $who = strtolower(sanitize_user($_POST['log'])); $redirect_to = get_option('home') . '/profile?' . $who; return $redirect_to; } add_filter('login_redirect', 'redirect_to_profile'); 1

答案 1 :(得分:0)

我找到了一个解决方案,至少在我的具体情况下。错误是TreeView中的ItemContainerStyle定义。为Window/UserControl定义TreeViewItem资源的样式,如下所示:

<Style TargetType="TreeViewItem">
    <Setter Property="KeyboardNavigation.TabNavigation" Value="Continue"/>
    <Setter Property="IsTabStop" Value="False"/>
  </Style>