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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:57:54+00:00 2026-05-22T02:57:54+00:00

I have run into issues when hosting a WinForms form within a WindowsFormsHost and

  • 0

I have run into issues when hosting a WinForms form within a WindowsFormsHost and the tab navigation. To solve I have made this simple example:

  • Created WPF Window (starting point of app)
  • Created WinForms Form with two TextBox on it
  • WPF window: Added WindowsFormsHost to it
  • WPF window: Added OnLoaded handler
  • WPF window: Added Textbox positioned under the WindowsFormsHost

In the OnLoaded handler I got:

System.Windows.Forms.Form f = new WinFormsForm();
f.TopLevel = false;
f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.windowsFormsHost1.Child = f;

When I now run the application:

  • Nothing is focussed (ok)
  • I click on the first TextBox in the WindowsFormsHost, it gets focus (ok)
  • I press tab, focus goes to 2nd TextBox in the WindowsFormsHost (ok)
  • I press tab again, focus goes back to 1st TextBox in the WindowsFormsHost (not ok; should have left WindowsFormsHost and given focus to the textbox at the bottom of the WPF window)
  • I click on the textbox in the wpf (placed after and under the WindowsFormsHost), it gets focus (ok)
  • I press tab, focus goes to 1st textbox in WindowsFormsHost – as it should go to beginning after the end. So this is ok too
  • I click the wpf textbox again and press shift+tab, focus goes to 2nd textbox in WindowsFormsHost (ok)
  • I press tab, focus goes to 1st textbox in WindowsFormsHost (goes to beginning in WFH) (not ok)

How do I make the focus behave like if I had only controls of one type? Meaning a tab order of WFH-1st-Textbox, WFH-2nd-Textbox, WPF-Textbox in this case.

  • 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-22T02:57:55+00:00Added an answer on May 22, 2026 at 2:57 am

    According to the articles I have found, that seems not possible to accomplish. According to a MSDN Blog Entry (section Hwnds) the Windows Forms controls always are on top of WPF controls in the hierarchy. The MSDN article (section Acquiring Messages from the WPF Message Loop) states that events occurring in a WindowsFormsHost element will be processed before WPF is even aware of them.

    So I assume that the event fired by pressing the TAB key is processed by the WindowsFormsHost element (resulting in the focus of the other textbox). In the enclosing WPF window the event will never be encountered because “it has already been processed”. On the other side when you press the TAB key in the WPF textbox, WPF is handling the event itself and the control chain is processed normally. With this the focus will get to a textbox in the WindowsFormsHost element and from there you can’t leave it using the keyboard.

    I know this will not help your current problem but I hope it explains some things.


    ADDENDUM
    If you are not dependent on using a form control, you could change it into a WinForms user-control with the same control elements in it. After that you change the initialization of the WindowsFormsHost element in the following way:

    System.Windows.Forms.UserControl control = new WinFormUC();
    windowsFormsHost1.Child = control;
    

    The class WinFormUC is my WinForms user-control containing the mentioned textboxes. In my test the pressing of the TAB key focused the textboxes one after another regardless whether its a Winforms or a WPF textbox.

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

Sidebar

Related Questions

I never actually thought I'd run into speed-issues with python, but I have. I'm
I have run into this problem before but never quite solved it. I have
I am using boost's threading library and have run into linking issues in Visual
I have run into some issues lately w/ using IE8 to test a web
I'm working with VS 2010 CUIT projects and have run into some issues that
I'm working on an NPAPI plugin on Linux and have run into several issues
I have run into an issue with WPF and Commands that are bound to
I'm working on some screen scraping software and have run into an issue with
I have recently run into a particularly sticky issue regarding committing the result of
a day before end of project i run into a complicated issue: i have

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.