WPF Radio Button Group Behavior
-
Is there a way to make radio button groups behave as they do in Windows Forms? By that I mean when you hit tab, the focus moves to the next control following the group rather than the next radio button in the group and when you use the up and down keys, the checked state follows the selected radio button rather than having to hit space to select it. Thanks. Eric
-
Is there a way to make radio button groups behave as they do in Windows Forms? By that I mean when you hit tab, the focus moves to the next control following the group rather than the next radio button in the group and when you use the up and down keys, the checked state follows the selected radio button rather than having to hit space to select it. Thanks. Eric
The arrow keys one is a simple fix. Just add a trigger that targets the RadioButton control. Something like: <Style.Triggers> <Trigger Property="IsKeyboardFocusWithin" Value="True"> <Trigger.Setters> <Setter Property="IsChecked" Value="True" /> </Trigger.Setters> </Trigger> </Style.Triggers> As for the tab one... thats a little bit trickier. I don't really feel like writing code on a Saturday night, but if I was, I'd probably derive a class from RadioButton, override the key down and if its a tab, I'll search for the next control thats either not a radio button or not in the group. Keep in mind that shift-tab should work the other way :). Previous control I mean. I don't think you can fix that in xaml.