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

  • SEARCH
  • Home
  • 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 9082493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:34:18+00:00 2026-06-16T20:34:18+00:00

I have the following visual tree: <DockPanel> <TextBox Name=ElementWithFocus DockPanel.Dock=Left /> <ListBox DockPanel.Dock=Left Width=200

  • 0

I have the following visual tree:

<DockPanel>
    <TextBox Name="ElementWithFocus" DockPanel.Dock="Left" />
    <ListBox DockPanel.Dock="Left" Width="200" KeyUp="handleListBoxKeyUp">
        <ListBoxItem>1</ListBoxItem>
        <ListBoxItem>4</ListBoxItem>
        <ListBoxItem>3</ListBoxItem>
        <ListBoxItem>2</ListBoxItem>
    </ListBox>
    <TextBox DockPanel.Dock="Left" />
</DockPanel>

handleListBoxKeyUp is the following:

private void handleListBoxKeyUp(object sender, KeyEventArgs e)
{
    if (e.Key == Key.Enter)
    {
        ((UIElement)sender).MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
    }
}

When the ListBox has keyboard focus (really a ListBoxItem I’d guess), pressing Enter moves the focus to the first item in the ListBox instead of to the following TextBox. Why is this happening and how can I get the Enter key to act like Tab here?

  • 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-06-16T20:34:19+00:00Added an answer on June 16, 2026 at 8:34 pm

    Rather than calling MoveFocus on the sender, you should call it on the original source found in the event args.

    The sender parameter will always be the ListBox itself, and calling MoveFocus on that with FocusNavigationDirection.Next will go to the next control in the tree, which is the first ListBoxItem.

    The original source of the routed event will be the selected ListBoxItem, and the next control after that is the TextBox that you want to receive focus.

    ((UIElement)e.OriginalSource).MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following visual tree for which I am trying to send a
I have the following configuration: Visual Studio Team System 2008 SQL Server Developer Edition
I have the following code behind a button in Visual Studio 2010 private void
Visual Studio C++ 2008 I have the following code in my server.h file. #if
I have the following array: a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] I use it for some visual
Hi I have a visual studio project which includes postbuildevents in the following form:
I have selected text by visual mode and pressed :. I run the following
i have following code in visual c++ #include<Windows.h> LPCTSTR Caption=LApplication programming INTERFACE; INT WINAPI
Consider the following part of a visual tree in a Windows Phone SL application:
I have following code with error: (Visual Studio error:)Error 5 error C2678: binary '!='

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.