私は宣言しました<InputBindings>
<UserControl.InputBindings>
<KeyBinding Key="C" Modifiers="Ctrl" Command="{Binding CopyImageCommand}" />
<KeyBinding Key="V" Modifiers="Ctrl" Command="{Binding PasteImageCommand}" />
</UserControl.InputBindings>
テスト目的で、これらのコマンドにバインドされたボタンも追加しました
<Button Command="{Binding CopyImageCommand}" Content="Copy" />
<Button Command="{Binding PasteImageCommand}" Content="Paste" />
貼り付けボタンが有効になっているときに Ctrl-V を押しても何も起こらないことに気付きました。Ctrl-C が機能するようです。そのために、リストボックスの項目が選択されていますが、違いがあるかどうかはわかりません。PasteImageCommand
なぜ私がトリガーしないのか誰にも分かりますか?
私は.NET 4を使用しています
アップデート
より完全なコード スニペット
<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="*" />
アップデート
KeyBindings
MainWindow にを配置する必要があることがわかりましたが、コマンドは にありViewModel
ます。ShellView
ShellViewModel