Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
115
Access Key in RibbonTabItem
posted

Hello

 

I have encountered a Problem in the Ribbon Control concerning the Access Key ("_"). My texts containing the _ character are not correctly displayed, namely the first _ in the string is always missing (example: KRD_AZ_RDTZ_09 is displayed as KRDAZ_RDTZ_09). I would like to turn off the Recognition of the Access Key for the RibbonTabItem Control (and some other Controls;preferably for all Controls).

 

I managed to find a solution, which is not optimal IMO. That is using the default style of the Control, going through the XML to find the ContentPresenter and turning the RecognizeAccessKey Property off (setting it to false). With this I get the display I want but as said it is not optimal. I was also searching and exploring other ideas but I could not find any other way to affect this property.

 

I was therefore wondering if I missed something, can this "Feature" be turned of some how without overriding the default style? (Preferably for all Controls)

 

I am using the WPF 2012 Vol. 2 Controls.

 

Thanks in advance for your answer.

 

Regards BB

Parents
  • 54937
    Verified Answer
    Offline posted

    As you noted you can change the styles so that the RecognizesAccessKey property of the ContentPresenter is set to false. There are a couple of other options. You can change your string so that it has two consecutive "_" underscores (i.e. escape the underscore). Another option might be to set the HeaderTemplate of the RibbonTabItem to a DataTemplate that just uses a TextBlock. Internally the ContentPresenter uses the RecognizesAccessKey to determine if it should create a TextBlock or an AccessText for the string it is representing (assuming it is a string and that string contains a mnemonic).

Reply Children