Application-wide KeyBinding

Nov 24, 2014 at 4:38 PM
I currently have the following code in my MainWindow.xaml to execute a command when Ctrl+N is pressed. I am curious if there is something in SimpleMVVM that I can use that is simpler, more streamlined, etc. than what I am currently doing.

<Window x:Class="CallTracker.WPF.MainWindow"
        <KeyBinding Command="{Binding NewCallCommand}" Modifiers="Control" Key="N"/>
And I have the following in my MainPageViewModel.cs to handle the key press:
    public class MainPageViewModel : ViewModelBase<MainPageViewModel>

        private readonly DelegateCommand newCallCommand;

        // Default ctor
        public MainPageViewModel()
            newCallCommand = new DelegateCommand(NewCall);

        public ICommand NewCallCommand { get { return newCallCommand; } }

        private void NewCall()
            MessageBox.Show("NewCallCommand executed.");
Nov 25, 2014 at 2:58 PM
To me it looks like you're on the right track. For more info, this article seems like a good one to check out: