Hey, I have using your control RadMenuGroupItem with ItemsSource that is Observable Collection of string. I noticed that for name with underscore in them, the underscore is removed from the name. Here an example:
telerik_123 will turn to telerik123
I use the same ItemsSource in a RadComboBox and in there I don't have this issue.
What can I do to solve this?
Sincerely, Omer
2 Answers, 1 is accepted
Hello Omer,
The underscore character in the Header property will turn the key into Access Key and allows you to reach a specific RadMenuItem inside a RadMenu control. More information about access key support can be found in our online resources.
Could you confirm for me what you want to achieve - to disable the access key support of RadMenu`s items or other behavior?
Regards,
Ralitsa
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hello Ralitsa,
I just want that the strings of the observable collection won't be modified - for example, that telerik_123 will still be displayed as telerik_123 (and not telerik123). If it means to disable the feature of the access key support, it is fine with me.
Thanks, Omer
Hi Omer,
In this case, I can suggest extracting and updating the ControlTemplate of the RadMenuGroupItem to set the RecognizesAccessKey property of the ContentPresenter inside it to False. Here is the code snippet based on the Office_Black theme:
<Window x:Class="MenuApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
xmlns:local="clr-namespace:MenuApp"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.Resources>
<SolidColorBrush x:Key="MenuHeaderBackground" Color="#FFDEDEDE"/>
<Style x:Key="MenuGroupStyle" TargetType="telerik:RadMenuGroupItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="telerikNavigation:RadMenuGroupItem">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="HeaderStates">
<VisualState x:Name="EmptyHeader">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Header" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0:0:0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="VisibleHeader"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border x:Name="Header" Background="{StaticResource MenuHeaderBackground}" Margin="1 1 1 0">
<ContentPresenter x:Name="Content"
Margin="4 2"
TextBlock.FontWeight="Bold"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
RecognizesAccessKey="False"
ContentSource="Header"/>
</Border>
<ScrollViewer x:Name="PART_ScrollViewer"
Grid.Row="1"
Margin="0"
BorderThickness="0"
Padding="0"
Background="Transparent"
HorizontalScrollBarVisibility="{Binding (ScrollViewer.HorizontalScrollBarVisibility), RelativeSource={RelativeSource TemplatedParent}}"
VerticalScrollBarVisibility="{Binding (ScrollViewer.VerticalScrollBarVisibility), RelativeSource={RelativeSource TemplatedParent}}"
Focusable="False">
<ItemsPresenter/>
</ScrollViewer>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<telerik:RadMenu VerticalAlignment="Top" x:Name="defaultMenu" >
<telerik:RadMenuItem Header="Shapes">
<telerik:RadMenuGroupItem Header="Group _item" Style="{StaticResource MenuGroupStyle}" >
<telerik:RadMenuItem Header="XSmall" />
<telerik:RadMenuItem Header="XM_edium" />
<telerik:RadMenuItem Header="XLarge" />
</telerik:RadMenuGroupItem>
</telerik:RadMenuItem>
<telerik:RadMenuItem Header="Sizes">
<telerik:RadMenuGroupItem>
<telerik:RadMenuItem Header="Small" />
<telerik:RadMenuItem Header="Medium" />
<telerik:RadMenuItem Header="Large"/>
</telerik:RadMenuGroupItem>
</telerik:RadMenuItem>
</telerik:RadMenu>
</Grid>
</Window>
Hope this helps.
Regards,
Ralitsa
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.