选定的 RadioButton 接收无序选项卡
我有一个自定义控件:定义一组 ListItemBox 的列表框,每个列表框都包含一个单选按钮。
我没有为每个单独设置 TabIndex,因为列表是动态读取的并填充控件的 ItemsSource。相反,我在 ListBox 本身上设置了 KeyboardNavigation="Local" 。
这工作得很好(我正在浏览表单,点击列表框,按顺序浏览其中的每个项目,然后继续浏览表单的其余部分),直到我选择一个单选按钮。
选择单选按钮后,当我尝试再次开始通过选项卡浏览列表框时,第一个选项卡将我发送到所选项目,跳过列表中该项目之前出现的所有项目。
有什么方法可以阻止这种不良行为的发生(最好是在 XAML 中,而不是在代码隐藏中)?
I have a custom control: a Listbox defining a set of ListItemBox's, which each contain a RadioButton.
I have not set the TabIndex for each of these individually, as the list is being read in dynamically and populating the control's ItemsSource. Rather, I have set KeyboardNavigation="Local" on the ListBox itself.
This works fine (I am tabbing through my form, hit the listbox, tab through each item in it - in order - and then continue tabbing through the rest of my form) until I select a radio button.
After a radio button is selected, when I try to start tabbing through my list box again, the first tab sends me to the selected item, skipping all the items that appear prior to that item in the list.
Is there any way to stop this bad behavior from occurring (preferrably in XAML, not in code behind)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是列表框选项卡的正常行为。一旦列表框的第一个项目获得焦点,您就可以使用向上向下箭头键导航到其他项目。
如果您想更改选项卡的行为,这里已经做了一些事情列表框中的文本框。希望您可以更新并使用这种方式来处理单选按钮。
That's the normal behavior of ListBox tabbing. Once the first item of the ListBox gets the focus you can navigate to other items by using up down arrow keys.
If you want to change the behavior of tabbing, here is something that has been done for TextBoxes which are in a ListBox. Hopefully you could update and use that way for RadioButtons.
我最终从列表框中删除了按钮。使用列表框是从单选按钮上绑定丢失的老问题中遗留下来的,但我的测试表明这个问题在 4.0 中已得到修复。一旦单选按钮不再位于列表框中,选项卡行为就可以满足需要。
I ended up removing the buttons from the listbox. Using the listbox was carried over from the old problem where bindings were being lost on radio buttons, but my tests indicate this was fixed in 4.0. Once the radio buttons were no longer in a list box, tabbing behavior was as desired.