This is a migrated thread and some comments may be shown as answers.

RadMenuItem HotKey Not Firing Command

2 Answers 474 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Barry
Top achievements
Rank 1
Barry asked on 03 Nov 2017, 06:49 PM

The snippet below is from an application for a machine shop which has a rather utilitarian menu.... I've been asked to add hot keys to some of the items; one of the menu items (as seen in the code below) I need to add the F6 key as a hotkey (note the idendical Command for clicking vs hotkey)...   clicking on it works as desired, but the hotkey has seemingly no effect whatsoever.

 

What am I missing, or otherwise doing wrong? Thanks in advance for your help.

 

        <telerik:RadMenuItem Name="ToolsMenu" Header="Tools">
            <telerik:RadMenuItem Name="ToolsUseFinishLocationMenuItem" Header="Use Finish Location For Bin" Command="{Binding ToolsUseFinishLocationForBinCommand}" InputGestureText="F6">
                <telerik:RadMenuItem.InputBindings>
                    <KeyBinding Key="F6" Command="{Binding ToolsUseFinishLocationForBinCommand}" />
                </telerik:RadMenuItem.InputBindings>
            </telerik:RadMenuItem>
        </telerik:RadMenuItem>

2 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 08 Nov 2017, 11:05 AM
Hello Barry,

The reason for this issue has been described in the following thread. Using the InputBindingBehavior suggested there, you can define your RadMenu like so:

<telerik:RadMenu local:InputBindingBehavior.PropagateInputBindingsToWindow="True">
    <telerik:RadMenu.InputBindings>
        <KeyBinding Key="F6" Command="{Binding ToolsUseFinishLocationForBinCommand}" />
    </telerik:RadMenu.InputBindings>
    <telerik:RadMenuItem Name="ToolsMenu" Header="Tools" >
        <telerik:RadMenuItem Name="ToolsUseFinishLocationMenuItem" Header="Use Finish Location For Bin" Command="{Binding ToolsUseFinishLocationForBinCommand}" InputGestureText="F6" />
    </telerik:RadMenuItem>
</telerik:RadMenu>

Please let me know if this works for you.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Tayyaba
Top achievements
Rank 1
answered on 07 Feb 2018, 07:14 AM

Hi,

I'm also trying to use inputBindigns on my RadContextMenu items but they aren't working as i'm setting them in style as shows in code below:

<Style x:Key="MenuItemContainerCustom" TargetType="telerik:RadMenuItem">
    <Setter Property="Header" Value="{Binding Text}"/>
    <Setter Property="telerik:InputBindingsManager.InputBindings">
        <Setter.Value>
            <InputBindingCollection>
                <KeyBinding Key="{Binding DataContext.Key}" Modifiers="{Binding DataContext.Modifier}" Command="{Binding DataContext.Command}" />
            </InputBindingCollection>
        </Setter.Value>
    </Setter>
    <Setter Property="HeaderTemplate">
        <Setter.Value>
            <DataTemplate>
 
                <Grid Margin="-27,0,-30,0" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="25" />
                        <ColumnDefinition Width="1*" />
                    </Grid.ColumnDefinitions>
                    <StackPanel  Grid.Column="0"  Orientation="Horizontal" Margin="0 0 5 0">
                        <CheckBox  IsChecked="{Binding Path=DataContext.IsChecked, Mode=OneWay ,  RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadMenuItem}}}"  Command="{Binding Path=DataContext.Command, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadMenuItem}}}"  Visibility="{Binding Path=DataContext.IsCheckboxEnabled, Mode=TwoWay,  RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadMenuItem}},Converter={StaticResource CheckBoxVisibilityConverter}}">
                        </CheckBox>
                    </StackPanel>
                    <StackPanel  Grid.Column="1" Orientation="Horizontal" Margin="0">
                        <TextBlock Text="{Binding}"/>
                    </StackPanel>
                </Grid>
 
            </DataTemplate>
        </Setter.Value>
    </Setter>
    <Setter Property="IsSeparator" Value="{Binding IsSeparator}" />
    <Setter Property="Command" Value="{Binding Command}"/>
    <Setter Property="IsEnabled" Value="{Binding IsMenuItemEnabled}"/>
</Style>
 
<Style x:Key="ContextMenuStyle" TargetType="{x:Type telerik:RadTreeViewItem}" BasedOn="{StaticResource SelectionStyle}">
    <Setter Property="telerik:RadContextMenu.ContextMenu">
        <Setter.Value>
            <telerik:RadContextMenu Width="{Binding ContextMenu.Width}"
                                        InheritDataContext="False" IsOpen="{Binding ContextMenu.IsOpened, Mode=TwoWay}"
                                        DataContext="{Binding UIElement.ParentTreeView.DataContext, RelativeSource={RelativeSource Self}}"
                                        ItemsSource="{Binding ContextMenu.MenuItems}"
                    ItemContainerStyle="{StaticResource MenuItemContainerCustom}">
                <telerik:EventToCommandBehavior.EventBindings>
                    <telerik:EventBinding EventName="Opening" Command="{Binding ContextMenuOpeningCommand}" CommandParameter="{Binding Path=UIElement.Item, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=telerik:RadContextMenu}}" />
                </telerik:EventToCommandBehavior.EventBindings>
            </telerik:RadContextMenu>
        </Setter.Value>
    </Setter>
</Style>

Let me know what am i doing wrong in the style block for setting inputBindings?

Thank you in advance

Tayyaba,

 

Tags
Menu
Asked by
Barry
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Tayyaba
Top achievements
Rank 1
Share this question
or