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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:15:32+00:00 2026-06-07T22:15:32+00:00

I have a solution, that has two projects, the main one and a small

  • 0

I have a solution, that has two projects, the main one and a small shared control that’s used as well. In our application, a certain feature opens this shared control in a new window. I want to set the focus to the first combobox in this control when the window opens.

In my code, on the window that loads the shared control, at the end of the _Loaded event, I set focus to this combobox. But when running the code – I still have to hit tab to have ‘keyboard’ focus on the box (as in, I would have to hit tab to then start typing the name of one of the items in the list).

If I set a breakpoint here, hit it, and then continue – it actually is set the way it should be. If I use a WPF inspector – IsFocused is also set.

Other things noticed:

  • If I hit tab (to get what I want), then tab back, it takes me to the last control on the form, not to this unknown control. This makes me believe the focus is set right, but for some reason doesn’t have correct keyboard focus.
  • If I try to use MoveNext in code, it actually selects the next item in the window, outside of the control.

How do I properly set focus here? On another combobox in the ‘main’ project, just calling .Focus() worked correctly.

  • 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-07T22:15:34+00:00Added an answer on June 7, 2026 at 10:15 pm

    try to postpone the focus() after all events are handled and bindings updated with QueueUserWorkItem. Something like this :

       public  delegate void  VoidDelegate();
    
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Some other things to do here.
            System.Threading.ThreadPool.QueueUserWorkItem
                           (x => this.Dispatcher.Invoke(
                                      new VoidDelegate(SetFocus), null));
        }
    
        private void SetFocus()
        {
            MyControlIWantToSetFocusOn.Focus();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a solution that contains two projects. One project is an ASP.NET Web
I have a VS2010 solution that has two projects. The first project [DevLib] is
I have a Ruby on Rails application that has two active environments, Stage and
I have two projects in this solution: ProjectA and ProjectB. ProjectA is the main
I have a web application (MVC3) that is an Intranet, Main app. The solution
My C# WinForms solution has two projects. A DLL which is the main project
I have a Solution that has two class libraries. I'm trying to convert the
I have a solution file that has the following example projects: SharedLibrary NonSharedLibrary WebProject
I have two executable projects in my Solution. One is the primary program, and
I have two separete c# projects. One is a helper library that is included

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.