我的控件是由嵌套列表框和树视图构成的。 每个列表框/树视图项还包含富文本框和其他控件。
我想定义一个'标签'焦点行为,这样当用户点击'Tab'时,下一个可聚焦项目(根据我定义的顺序)将变得集中。
目前它不起作用,因为我接受(它只能部分工作)。
我的问题不是针对我的情况而是针对如何定义这种行为。 作为一个极端的例子,假设我想完全控制它并使焦点跳到物理上不接近的物品之间。
任何人都可能知道如何控制它?
答案 0 :(得分:3)
<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>
答案 1 :(得分:1)
您在寻找KeyboardNavigation.TabIndex财产吗?