RadMenuItem HotKey Not Firing Command

3 posts, 0 answers
  1. Barry
    Barry avatar
    3 posts
    Member since:
    Jan 2017

    Posted 03 Nov 2017 Link to this post

    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. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    718 posts

    Posted 08 Nov 2017 Link to this post

    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.
  3. Tayyaba
    Tayyaba avatar
    34 posts
    Member since:
    Apr 2017

    Posted 07 Feb Link to this post

    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,

     

Back to Top