We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to use an access key to open the dropdown menu

I want to use an access key on the label to trigger the opening of the dropdown menu. In my case, the label is "Appl_y Template" and I want to press Alt+Y to open the menu. The window is opened via ShowDialog() method. I modified the template and change the TextBlock to a Label control. But I don't know what the target is? How to trigger the dropdown menu from the template? Could you assist me with this?


3 Replies

HN Harinath Navaneethakrishnan Syncfusion Team December 7, 2022 03:07 PM UTC

Hi Herbert,


It is not possible to open the dropdownmenu using the access keys. However, your requirement can be achieved by focusing the DropDownButtonAdv using the access keys and opening the drop-down in the OnGotFocus event. Please refer to the sample for your reference


Regards,

Harinath N


Attachment: DropDownButtonAdv_a69bc6fa.zip


HE Herbert December 8, 2022 03:18 AM UTC

Thanks for your help. Your sample does work when accessing the drop down button using the access key but breaks the mouse behaviour. When you click the button with the mouse, the drop down menu opens and immediately closes. You must click the mouse again to open the menu. This is not a good solution. Is there a way to detect whether the control is clicked using a mouse in the GotFocus event?



GT Gokul Thanudhas Syncfusion Team December 9, 2022 03:57 PM UTC

You can achieve your requirement by detecting whether the key is pressed in the GotFocus event. Please refer the sample for your reference.


Code Snippets


private void DropDownButtonAdv_GotFocus(object sender, RoutedEventArgs e)
{
    if (Keyboard.IsKeyDown(Key.Y))
        {
            dropDownButtonAdv.IsDropDownOpen = true;
         }
}

Attachment: DropDownButtonAdv_29d8bbce.zip

Loader.
Live Chat Icon For mobile
Up arrow icon