C#/WPF: Raccourci clavier pas de déclenchement de Commande

Je l'ai déclaré à <InputBindings>

<UserControl.InputBindings>
    <KeyBinding Key="C" Modifiers="Ctrl" Command="{Binding CopyImageCommand}" />
    <KeyBinding Key="V" Modifiers="Ctrl" Command="{Binding PasteImageCommand}" />
</UserControl.InputBindings>

Des fins de test, j'ai ajouté des boutons liés à ces commandes trop

<Button Command="{Binding CopyImageCommand}" Content="Copy" />
<Button Command="{Binding PasteImageCommand}" Content="Paste" />

J'ai remarqué que quand la pâte bouton est activé, lorsque j'appuie sur Ctrl-V rien ne se passe. Ctrl-C semble fonctionner. Pour cela, un élément de zone de liste est sélectionné, je ne suis pas sûr si cela fait une différence. Quelqu'un sait pourquoi mon PasteImageCommand pas de déclenchement?

Je suis à l'aide .NET 4 btw

Mise à JOUR

Une meilleure code snipplet

<UserControl x:Class="QuickImageUpload.Views.ShellView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:vm="clr-namespace:QuickImageUpload.ViewModels"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.InputBindings>
        <KeyBinding Key="C" Modifiers="Ctrl" Command="{Binding CopyImageCommand}" />
        <KeyBinding Key="V" Modifiers="Ctrl" Command="{Binding PasteImageCommand}" />
    </UserControl.InputBindings>
    <UserControl.DataContext>
        <vm:ShellViewModel />
    </UserControl.DataContext>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="50" />
            <RowDefinition Height="*" />

Mise à JOUR

J'ai trouvé j'ai besoin de mettre la KeyBindings dans la MainWindow, mais les commandes sont dans le ViewModel, comment puis-je définir des raccourcis clavier dans le ShellView qui se lie alors aux commandes dans le ShellViewModel?

Pouvez-vous s'il vous plaît poster où sont InputBinding spécifié? Son possible que vous mettez dans le mauvais endroit.
J'ai mis mon InputBindings dans le contrôle UserControl ShellView. J'ai découvert il fonctionne quand je les ai mis dans la MainWindow, mais j'ai besoin de configurer le modèle de vue de ShellViewModel, pas vraiment correcte je pense, comment puis-je gérer cela?
Salut jiew! j'ai presque le même problème. avez-vous trouvé la solution?
Je n'ai pas fait de C# pour un certain temps, je crains que je ne peux pas me rappeler si j'ai résolu ce problème 🙁

OriginalL'auteur Jiew Meng | 2010-10-15