WPF:复杂的选项卡焦点行为

WPF:复杂的选项卡焦点行为,wpf,listbox,focus,nested,Wpf,Listbox,Focus,Nested,我的控件由嵌套列表框和树视图构成。 每个列表框/树视图项还包含富文本框和其他控件 我想定义一个“tab”焦点行为,这样当用户单击“tab”时,下一个可焦点项目(根据我定义的顺序)将成为焦点 目前它不工作,因为我接受(它只是部分工作) 我的问题并不是针对我的情况,而是如何定义这种行为。 作为一个极端的例子,假设我想完全控制这一点,并使焦点在物理上不接近的项目之间跳跃 任何人都可能知道这是如何控制的?你在找这个属性吗?你在找这个属性吗?乔,这个机制比我想象的要聪明,检查这个嵌套-它工作得很好: &l

我的控件由嵌套列表框和树视图构成。 每个列表框/树视图项还包含富文本框和其他控件

我想定义一个“tab”焦点行为,这样当用户单击“tab”时,下一个可焦点项目(根据我定义的顺序)将成为焦点

目前它不工作,因为我接受(它只是部分工作)

我的问题并不是针对我的情况,而是如何定义这种行为。 作为一个极端的例子,假设我想完全控制这一点,并使焦点在物理上不接近的项目之间跳跃


任何人都可能知道这是如何控制的?

你在找这个属性吗?

你在找这个属性吗?

乔,这个机制比我想象的要聪明,检查这个嵌套-它工作得很好:

<ListBox KeyboardNavigation.TabNavigation="Continue">
    <ListBoxItem Focusable="False">
        <ListBox KeyboardNavigation.TabNavigation="Continue">
            <ListBox.Items>
                <ListBoxItem Focusable="False">
                    <TextBox Width="300" KeyboardNavigation.TabIndex="1" Focusable="True"/>
                </ListBoxItem>
                <ListBoxItem Focusable="False">
                    <TextBox Width="300" KeyboardNavigation.TabIndex="2" Focusable="True"/>
                </ListBoxItem>
                <ListBoxItem Focusable="False">
                    <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                </ListBoxItem>
            </ListBox.Items>
        </ListBox>
    </ListBoxItem>
    <ListBoxItem Focusable="False">
        <ListBox KeyboardNavigation.TabNavigation="Continue">
            <ListBox.Items>
                <ListBoxItem Focusable="False">
                    <TextBox Width="300" KeyboardNavigation.TabIndex="1" Focusable="True"/>
                </ListBoxItem>
                <ListBoxItem Focusable="False">
                    <StackPanel>
                        <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                        <Border BorderBrush="Red">
                            <ListBox KeyboardNavigation.TabNavigation="Continue">
                                <ListBoxItem Focusable="False">
                                    <ListBox KeyboardNavigation.TabNavigation="Continue">
                                        <ListBox.Items>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="1" Focusable="True"/>
                                            </ListBoxItem>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="2" Focusable="True"/>
                                            </ListBoxItem>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                                            </ListBoxItem>
                                        </ListBox.Items>
                                    </ListBox>
                                </ListBoxItem>
                                <ListBoxItem Focusable="False">
                                    <ListBox KeyboardNavigation.TabNavigation="Continue">
                                        <ListBox.Items>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="1" Focusable="True"/>
                                            </ListBoxItem>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="2" Focusable="True"/>
                                            </ListBoxItem>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                                            </ListBoxItem>
                                        </ListBox.Items>
                                    </ListBox>
                                </ListBoxItem>
                            </ListBox>
                        </Border>
                    </StackPanel>
                </ListBoxItem>
                <ListBoxItem Focusable="False">
                    <StackPanel>
                        <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                        <Border BorderBrush="Red">
                            <ListBox KeyboardNavigation.TabNavigation="Continue">
                                <ListBoxItem Focusable="False">
                                    <ListBox KeyboardNavigation.TabNavigation="Continue">
                                        <ListBox.Items>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="1" Focusable="True"/>
                                            </ListBoxItem>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="2" Focusable="True"/>
                                            </ListBoxItem>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                                            </ListBoxItem>
                                        </ListBox.Items>
                                    </ListBox>
                                </ListBoxItem>
                                <ListBoxItem Focusable="False">
                                    <ListBox KeyboardNavigation.TabNavigation="Continue">
                                        <ListBox.Items>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="1" Focusable="True"/>
                                            </ListBoxItem>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="2" Focusable="True"/>
                                            </ListBoxItem>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                                            </ListBoxItem>
                                        </ListBox.Items>
                                    </ListBox>
                                </ListBoxItem>
                            </ListBox>
                        </Border>
                    </StackPanel>
                </ListBoxItem>
            </ListBox.Items>
        </ListBox>
    </ListBoxItem>
</ListBox>

乔,这个机制比我想象的要聪明,检查一下这个嵌套-它工作得非常好:

<ListBox KeyboardNavigation.TabNavigation="Continue">
    <ListBoxItem Focusable="False">
        <ListBox KeyboardNavigation.TabNavigation="Continue">
            <ListBox.Items>
                <ListBoxItem Focusable="False">
                    <TextBox Width="300" KeyboardNavigation.TabIndex="1" Focusable="True"/>
                </ListBoxItem>
                <ListBoxItem Focusable="False">
                    <TextBox Width="300" KeyboardNavigation.TabIndex="2" Focusable="True"/>
                </ListBoxItem>
                <ListBoxItem Focusable="False">
                    <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                </ListBoxItem>
            </ListBox.Items>
        </ListBox>
    </ListBoxItem>
    <ListBoxItem Focusable="False">
        <ListBox KeyboardNavigation.TabNavigation="Continue">
            <ListBox.Items>
                <ListBoxItem Focusable="False">
                    <TextBox Width="300" KeyboardNavigation.TabIndex="1" Focusable="True"/>
                </ListBoxItem>
                <ListBoxItem Focusable="False">
                    <StackPanel>
                        <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                        <Border BorderBrush="Red">
                            <ListBox KeyboardNavigation.TabNavigation="Continue">
                                <ListBoxItem Focusable="False">
                                    <ListBox KeyboardNavigation.TabNavigation="Continue">
                                        <ListBox.Items>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="1" Focusable="True"/>
                                            </ListBoxItem>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="2" Focusable="True"/>
                                            </ListBoxItem>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                                            </ListBoxItem>
                                        </ListBox.Items>
                                    </ListBox>
                                </ListBoxItem>
                                <ListBoxItem Focusable="False">
                                    <ListBox KeyboardNavigation.TabNavigation="Continue">
                                        <ListBox.Items>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="1" Focusable="True"/>
                                            </ListBoxItem>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="2" Focusable="True"/>
                                            </ListBoxItem>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                                            </ListBoxItem>
                                        </ListBox.Items>
                                    </ListBox>
                                </ListBoxItem>
                            </ListBox>
                        </Border>
                    </StackPanel>
                </ListBoxItem>
                <ListBoxItem Focusable="False">
                    <StackPanel>
                        <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                        <Border BorderBrush="Red">
                            <ListBox KeyboardNavigation.TabNavigation="Continue">
                                <ListBoxItem Focusable="False">
                                    <ListBox KeyboardNavigation.TabNavigation="Continue">
                                        <ListBox.Items>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="1" Focusable="True"/>
                                            </ListBoxItem>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="2" Focusable="True"/>
                                            </ListBoxItem>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                                            </ListBoxItem>
                                        </ListBox.Items>
                                    </ListBox>
                                </ListBoxItem>
                                <ListBoxItem Focusable="False">
                                    <ListBox KeyboardNavigation.TabNavigation="Continue">
                                        <ListBox.Items>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="1" Focusable="True"/>
                                            </ListBoxItem>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="2" Focusable="True"/>
                                            </ListBoxItem>
                                            <ListBoxItem Focusable="False">
                                                <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                                            </ListBoxItem>
                                        </ListBox.Items>
                                    </ListBox>
                                </ListBoxItem>
                            </ListBox>
                        </Border>
                    </StackPanel>
                </ListBoxItem>
            </ListBox.Items>
        </ListBox>
    </ListBoxItem>
</ListBox>