RadSplitButton Keyboard Navigation not Behaving as Expected

1 Answer 119 Views
Buttons
Ben
Top achievements
Rank 1
Ben asked on 19 Oct 2022, 04:46 PM
I have a Telerik RadSplitButton defined as follows:
<telerik:RadSplitButton Style="{StaticResource MySplitButtonStyle}" Content="Some Text" DropDownHeight="150">
  <telerik:RadSplitButton.DropDownContent>
    <ListBox>
      <ListBoxItem Content="Item 1" />
      <ListBoxItem Content="Item 2" />
      <ListBoxItem Content="Item 3" />
      <ListBoxItem Content="Item 4" />
      <ListBoxItem Content="Item 5" />
    </ListBox>
  </telerik:RadSplitButton.DropDownContent>
</telerik:RadSplitButton>
I am using the NoXaml version of the assemblies and so I have styled the split button based on a style that I got from a Telerik theme (Telerik.Windows.Controls.xaml file).  The style contains the following:
<Style x:Key="MySplitButtonStyle" TargetType="telerik:RadSplitButton">
  ...
  <Setter Property="ButtonPartStyle" Value="{StaticResource MyButtonStyle}"/>
  <Setter Property="IsToggle" Value="False"/>
  <Setter Property="IsTabStop" Value="True" />
  <Setter Property="IsOpen" Value="False" />
  <Setter Property="CloseOnPopupMouseLeftButtonUp" Value="True" />
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="telerik:RadSplitButton">
        ...
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>

When I use the Tab-Navigation to cycle through the controls on the page (because I have no mouse for example), this RadSplitButton gets the focus as expected.  So far so good.  However, when I then try to interact with this RadSplitButton using the keyboard (because I have no mouse) I can't seem to get the main button to activate and I cannot change the selected item in the drop-down.

When the RadSplitButton has focus:

- When I press the Spacebar or the Enter key, the drop-down opens but no events fires.  I would expect the button to get clicked or the Activate event to get fired.

- When I press the down-arrow key the drop-down opens and shows me the list box but the list box does not get keyboard focus and so I cannot navigate (using keys).  I cannot select an item from the drop-down as I can with a normal list box.

Can you suggest some changes that might help me to fix this?  Ideally, I would like to do this from the style and not have to add event handlers to every SplitButton.

Thanks

1 Answer, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 24 Oct 2022, 10:09 AM

Hello Ben,

Thank you for the shared code snippets. 

The RadSplitButton is comprised of two parts: a RadButton and a RadDropDownButton. The Click/Activate events are fired when the RadButton part of the control is clicked or activated. This does not happen when pressing the "space" or "enter" keys, which only opens the drop down section. 

That said, in order to achieve the desired result of focusing the element inside the DropDownContent, you can handle the DropDownOpened event (you can include an EventSetter in the Style to apply it to multiple controls) and focus the first item inside the ListBox. 

I am attaching a sample project demonstrating the above suggestion. Do check it out and let me know, if it helps. 

Regards,
Vladimir Stoyanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Ben
Top achievements
Rank 1
commented on 24 Oct 2022, 10:45 AM

Thank you for your reply.

Thank you for suggesting the EventSetter, I am less keen on this idea because EventSetters cannot be used in a theme ResourceDictionary.  However, I might be able to use a similar approach by attaching a Behaviour instead.

Tags
Buttons
Asked by
Ben
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
Share this question
or