Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6167081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:27:02+00:00 2026-05-23T22:27:02+00:00

I have a TextBox and a ListView in my window, and I’d like to

  • 0

I have a TextBox and a ListView in my window, and I’d like to move the ListView‘s selection up and down while the TextBox has focus:

enter image description here

However, I don’t seem to get my CommandTarget declarations across, they’re ignored. MSDN says this is default behavior for non-RoutedCommands, but the movement commands I try to use are RoutedUICommands, so this is probably not the problem here.

Am I missing something?

My XAML currently looks like this (code behind is empty):

<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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:27:02+00:00Added an answer on May 23, 2026 at 10:27 pm

    Actually since RoutedUICommand derives from RoutedCommand, both of them support a command target (the MSDN actually says command targets ONLY work on RoutedCommands, but what it means is it doesn’t work on other ICommand derived objects).

    Have you actually bound the ComponentCommands mentioned (MoveDown and MoveUp) into the ListView in your code behind? ListView is empty of command bindings when first created, so you’d need to do something like:

    AllItemsList.CommandBindings.Add(new CommandBinding(ComponentCommands.MoveDown, ExecuteMoveDown));
    

    You would then have to write your ExecuteMoveDown function to do the moving.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a setup, something confusing like this: <ListView> <ItemTemplate> <div id=Content> <asp: TextBox
I have 3 controls in a WPF window.. a textbox, listbox and listview. The
Possible Duplicate: Select ListBoxItem if TextBox in ItemTemplate gets focus I have a ListView
Im creating forum like application and I have textbox where users can enter tags
Desktop window application. I have textbox in which user give values in numbers. what
My window has just a listview. This facilitates the users to incremental search the
Say i have a TextBox control inside of a ListView where the text is
I have a textbox in a listview itemtemplate. I want to change the background
Say I have a ListView control with a TextBox control in the ItemTemplate: <asp:ListView
I have a series of textbox in a listview which contain the hours and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.