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
225
Key binding is not working in xammenu
posted

Hi,

I am trying to bind the command to xamMenuitem in hirerchialdatatemplate. Mousebindings are working as expected but keybinding is not working. On enter key i am trying to trigger to my viewmodel. can you please help in this.

please find below snippet.

 <Popup x:Name="ProductsPopup" Height="Auto" Focusable="True" StaysOpen="False" Closed="ProductsPopup_OnClosed" >

<ig:XamMenu IsTextSearchEnabled="True" x:Name="xamNavigator" MenuOrientation="Vertical" Focusable="True"
Width="150" ExpandOnHover="True" IsTextSearchCaseSensitive="False" MinHeight="180" Selector.IsSelected="True"
ItemsSource="{Binding ProductTypes}">

<ig:XamMenu.HierarchicalItemTemplate>
<ig:HierarchicalDataTemplate ItemsSource="{Binding ProductVariantList}">


<DataTemplate>
<Label Focusable="True" HorizontalAlignment="Left" HorizontalContentAlignment="Left" VerticalAlignment="Center" Foreground="White" Content="{Binding Path=ProductTypeName}">
<Label.InputBindings>
<MouseBinding Command="{Binding ProductTypeSelectCommand}" MouseAction="LeftClick" />
<KeyBinding Command="{Binding ProductTypeSelectCommand}" Key="Enter"></KeyBinding>
</Label.InputBindings>
</Label>
</DataTemplate>

<ig:HierarchicalDataTemplate.ItemTemplate>
<DataTemplate>

<Label Focusable="True" HorizontalContentAlignment="Left" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="White" Content="{Binding Path=ProductVariantName}" >

<Label.InputBindings>
<MouseBinding Command="{Binding ProductVariantSelectCommand}" MouseAction="LeftClick" />
<KeyBinding Command="{Binding ProductVariantSelectCommand}" Key="Enter"/>
</Label.InputBindings>
</Label>
</DataTemplate>

</ig:HierarchicalDataTemplate.ItemTemplate>
</ig:HierarchicalDataTemplate>
</ig:XamMenu.HierarchicalItemTemplate>

</Popup>

  • 2180
    Offline posted

    Hello viswa,

    Thank you for contacting Infragistics Developer Support.

    In order the KeyBinding for the Enter key to work, you have to add the binding to the xamMenuItem instead of to the Label control.

    I’ve attached a sample project to demonstrate this.

    Let me know if I may be of further assistance.

    MenuEnterCommand.zip