Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Key Binding does not work always in MVVM application

$
0
0

 Hi,

I have a Usercontrol which is designed as an MVVM application and hosted in another WPF application(by other parties).

Usercontrol is composed of Left side and Right side usercontrols.

To add the shortcut behavior on the usercontrols,i have defined Key Binding on the Left and Right side controls.

Shortcut keys are defined for Ctrl+C,Ctrl+V,Ctrl+P,Delete,Page Up,Page Down,Home and End.

 <UserControl.InputBindings>
        <KeyBinding Key="A" Modifiers="Control" Command="{Binding Path= SelectAllCommand}"/>
        <KeyBinding Key="None" Modifiers="Control" Command="{Binding Path= DeselectAllCommand}"/>
        <KeyBinding Key="X" Modifiers="Control" Command="{Binding Path= CutCommand}"/>
        <KeyBinding Key="C" Modifiers="Control" Command="{Binding Path= CopyCommand}"/>
        <KeyBinding Key="V" Modifiers="Control" Command="{Binding Path= PasteCommand}"/>
        <KeyBinding Key="P" Modifiers="Control" Command="{Binding Path= PrintCommand}"/>
        <KeyBinding Key="Delete" Command="{Binding Path= DeleteCommand}"/>
        <KeyBinding Key="Home" Command="{Binding Path= DisplayPageCommand}" CommandParameter="1"/>
        <KeyBinding Key="End" Command="{Binding Path= DisplayPageCommand}" CommandParameter="{Binding Path=PageCount}"/>
        <KeyBinding Key="PageUp" Command="{Binding Path= ScrollUpdateCommand}" CommandParameter="{Binding Path=PageUpValue}"/>
        <KeyBinding Key="PageDown" Command="{Binding Path= ScrollUpdateCommand}" CommandParameter="{Binding Path=PageDownValue}"/>
        <KeyBinding Key="Up" Command="{Binding Path= ScrollUpdateCommand}" CommandParameter="{Binding Path=ArrowUpValue}"/>
        <KeyBinding Key="Down" Command="{Binding Path= ScrollUpdateCommand}" CommandParameter="{Binding Path=ArrowDownValue}"/>
    </UserControl.InputBindings>

Problem is that shortcut works initially and in between shortcuts stop working (probably due to  control losing focus).

How to make the shortcuts work ?

Please suggest.

Regards

Vinutha

 

 

 


VINUTHA


Viewing all articles
Browse latest Browse all 18858

Trending Articles