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 6640565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:41:15+00:00 2026-05-25T23:41:15+00:00

Once again I can’t find a neat solution for a simple UI problem in

  • 0

Once again I can’t find a neat solution for a simple UI problem in WPF. I want the combo box drop down list to appear whenever combo box gets focus. So I wrote this in the got focus event:

 private void comboBoxAC_Cat_GotFocus(object sender, RoutedEventArgs e)
    {
        comboBoxAC_Cat.IsDropDownOpen = true;
    }

But now the problem is that once the drop down list opens, the application is kind of stuck in it. It can not come out of the drop down list no matter what I do, whether I press enter or anything. I tried registering to lost focus or other events but nothing seems to work. Here is a list of my event handlers in the application which become useless once I get inside the drop down list.

private void Grid_PreviewKeyDown(object sender, KeyEventArgs e)
    {
        var uie = e.OriginalSource as UIElement;
        if (e.Source is Button)
            return;
        if (e.Key == Key.Enter)
        {
            e.Handled = true;
            uie.MoveFocus(
            new TraversalRequrest(
            FocusNavigationDiection.Next));
        }
    }
    private void comboBoxAC_Cat_LostFocus(object sender, RoutedEventArgs e)
    {
        (sender as ComboBox).IsDropDownOpen = false;

    }

Can any one help me out with this please?

My Basic requirement is simple: Drop Down list should open as soon as Combobox is focused using tab or mouse. Then the user should be able to select the items and once he presses enter selecting a item from drop down list, it should close and focus should move to next ui element.

Now is it hard to achieve??? I thought that was exactly the functionality of a combobox

  • 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-25T23:41:16+00:00Added an answer on May 25, 2026 at 11:41 pm

    I don’t understand, If I use exactly this code below

        private bool returnedFocus = false;
    
        private void myComboBox_GotFocus(object sender, RoutedEventArgs e)
        {
            if (e.OriginalSource.GetType() != typeof(ComboBoxItem) && !returnedFocus)
            {
                cmb.IsDropDownOpen = true;
            }
        }
    
        private void myComboBox_LostFocus(object sender, RoutedEventArgs e)
        {
            if (e.OriginalSource.GetType() != typeof(ComboBoxItem))
            {
                ComboBox cb = (ComboBox)sender;
                returnedFocus = cb.IsDropDownOpen;
            }
        }
    

    I get exactly what i think you want, my combobox drop down opens when control get focus and if i choose a listitem pressing enter or through mouse click contol loses focus

    Isn’t that what you wanted?

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

Sidebar

Related Questions

Once again I have a problem which I can't find the solution to. A
Once again I'm asking this question, and still can't find any reasonable solution. I
Once again I find myself failing at some really simple task in C++. Sometimes
I'm once again turning to you since I can't find an answer anywhere else.
I think I've seen this done once, but I cannot find it again after
Math has defeated me once again. This is such a simple task, but I
I'm pulling my hair out (once again), trying to find a way to read
Origo is shutting down their SVN hosting, so I am once again forced to
What I want is pretty simple conceptually but I can't figure out how it
I'm very sure this problem has been solved, but I can't find any information

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.