creating RecognizesAccessKey for RadComboBox (underscore char is not showing)

1 Answer 121 Views
ComboBox Styling
Gennady
Top achievements
Rank 2
Iron
Iron
Gennady asked on 28 Jun 2022, 08:58 PM

Getting difficulties to override RecognizesAccessKey="False" for RadComboBox control using custom Style.

Does anybody has a sample to accomplish it?

Original problem: drop-down box is not displaying the very first underscore char. Example: combo box items a_b, c_d_e. Selecting any will renders as 'ab', not 'a_b' and 'cd_e' instead of 'c_d_e'

Above solution was proposed long ago (2010 source)  are there another solutions for the problem?

Thank you

Gennady
Top achievements
Rank 2
Iron
Iron
commented on 29 Jun 2022, 12:13 AM

more details.

Accelerator key is not active with this setting: <telerik:RadComboBox IsEditable="True">

But combobox is kind of strange with enabled editing.

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Vladimir Stoyanov
Telerik team
answered on 30 Jun 2022, 07:45 AM

Hello Gennady,

Thank you for the provided information. 

My current understanding is that the first "_" (underscore) character in the RadComboBoxItem is not displayed when the item is selected. Feel free to correct me, if I am wrong and elaborate on the scenario. 

I tested this behavior on my end, however I was not able to reproduce this behavior on my end. That is why I am attaching the sample project that I used for testing purposes. Can you check it out and see how it differs from the setup on your end?

Should you need any further assistance, you can modify the sample project to demonstrate the observed on your end behavior and send it back. This will hopefully allow me to investigate the scenario and better assist you.

I am looking forward to your reply.

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.

Gennady
Top achievements
Rank 2
Iron
Iron
commented on 30 Jun 2022, 08:42 PM

Hello, Vladimir.

I hope i'm close to solve my problem: missing the very first '_' char.

Thanks a lot for attaching sample project. It is working as expected: no underscore char is missing in combo box text window.

My company is using Telerik DLL's in noXaml fashion. All company's product styles contained in separate Intergraph.UX.WPF.Toolkit library. And, my guess, there is a problem using company custom styles. Deep diving in attept to override template property discovered that RecognizesAccessKeyProperty is ReadOnly and probably it is set in company DLL to 'True' when combo box is Not Editable. Which i think is a reason why Non-Editable combobox is loosing underscore char.

Did attach modified project, please, take a look why 3 different comboboxes behaving with different setups.

The first combobox is your original design: data loaded from ViewModel. It is Non-Editable but still is rendered text correctly. Second and third boxes are using data straight from the xaml. Second box is Editable and showing correct text but last one is Non-Editable and is loosing underscore char.

If you have suggestions what is wrong in my custom styles DLL or how to overcome default value, please, share.

Vladimir Stoyanov
Telerik team
commented on 04 Jul 2022, 11:27 AM

Thank you for the updated project. 

It seems that the custom style for the RadComboBox and the RadDropDownButton inside it enables the recognizing of access keys and that is why the first "_" character is lost.

That said, I tried setting the RadComboBoxProperties.RecognizesAccessKey attached property to False on the RadComboBox and on my end the underscore is shown. Here is what I have in mind:

<telerik:RadComboBox IsEditable="False" SelectedIndex="0" uxt:RadComboBoxProperties.RecognizesAccessKey="False">
                <telerik:RadComboBox.Items>
                    <telerik:RadComboBoxItem Content="a_b" />
                    <telerik:RadComboBoxItem Content="c_d_e" />
                </telerik:RadComboBox.Items>
</telerik:RadComboBox>

Can you give this a try and let me know, if it helps? 

 

Gennady
Top achievements
Rank 2
Iron
Iron
commented on 05 Jul 2022, 02:35 PM | edited

Hello, Vladimir,

It is working now correctly! Cannot believe it can be so simple solution!

One thing still is puzzling: why binding combo box data to view model process is setting RecognizesAccessKey prop to False? No matter if combo is editable or not.

Thank you a lot for your time!

Best regards,

Gennady

Vladimir Stoyanov
Telerik team
commented on 06 Jul 2022, 08:04 AM

I am glad to hear that the suggestion helped out.

To provide some context, in WPF the recognition of access keys comes from the ContentPresenter element. I used Snoop to observe that the RadComboBoxProperties.RecognizesAccessKey attached property is bound to the RecognizesAccessKey property of the ContentPresenter within the non-editable RadComboBox. The editable RadComboBox does not have a ContentPresenter inside it and that is why it does not recognize access keys. 

That said, the first RadComboBox (the one with its ItemsSource set) also has its RadComboBoxProperties.RecognizesAccessKey attached property set to True from its Style. I am not sure why the ContentPresenter inside it does not recognize access keys. You can investigate its custom Style/ControlTemplate to see, if there is something specific that can lead to this behavior. 

Of course, feel free to contact us again, if you have any other questions. 

Tags
ComboBox Styling
Asked by
Gennady
Top achievements
Rank 2
Iron
Iron
Answers by
Vladimir Stoyanov
Telerik team
Share this question
or