ウィンドウにaTextBox
とaがあり、フォーカスがあるときにの選択を上下ListView
に移動したいと思います。ListView
TextBox
しかし、私は自分の宣言を理解していないようCommandTarget
です。それらは無視されます。MSDNによると、これは非のデフォルトの動作ですRoutedCommands
が、私が使用しようとしている移動コマンドはRoutedUICommands
であるため、ここではおそらく問題ではありません。
私は何かが足りないのですか?
私のXAMLは現在次のようになっています(コードビハインドは空です):
<Window x:Class="WpfTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Test Window">
<StackPanel>
<TextBox>
<TextBox.InputBindings>
<!-- for some reason, these two won't work -->
<KeyBinding Key="Down"
Command="ComponentCommands.MoveDown"
CommandTarget="{Binding ElementName=AllItemsList}"/>
<KeyBinding Key="Up"
Command="ComponentCommands.MoveUp"
CommandTarget="{Binding ElementName=AllItemsList}"/>
</TextBox.InputBindings>
</TextBox>
<ListView x:Name="AllItemsList">
<ListViewItem>Item 1</ListViewItem>
<ListViewItem>Item 2</ListViewItem>
<ListViewItem>Item 3</ListViewItem>
</ListView>
</StackPanel>
</Window>