开发者

Selected RadioButton receives tab out of order

开发者 https://www.devze.com 2023-04-03 10:55 出处:网络
I have a custom control: a Listbox defining a set of ListItemBox\'s, which each contain a RadioButton.

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开发者_JS百科 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)?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号