Note that there are some explanatory texts on larger screens.

plurals
  1. POHost External Application in WPF TabControl
    text
    copied!<p>I have managed to create an example project that uses HwndHost to host Notepad (<em>not what my real project will be embedding</em>) inside a C# WPF tab control. For this, many thanks goes to those who replied to <a href="https://stackoverflow.com/questions/5028598/hosting-external-app-in-wpf-window">Hosting external app in WPF window</a> (<em>BTW there's no need for DwayneNeed</em>)</p> <p>This example works beautifully until you click on the hosted instance of Notepad, and <strong>then try to change tabs</strong>. If you don't have any content in the new page you are navigating to, you have to click on your current page selector first before it will accept a click on the other tab. If you have content on the other page (anything... just a button), then you are forced to click on the new tab selector TWICE to get it to navigate away.</p> <p><strong>Things I have tried that didn't work:</strong></p> <ul> <li>Using <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms681956.aspx" rel="nofollow noreferrer">AttachThreadInput()</a> to join the input threads of both application windows.</li> <li>Calling <code>this.InvalidateVisual();</code> on the Tab Control mouse down event.</li> </ul> <p><strong>What does the trick:</strong></p> <ul> <li>Programmatically changing the <code>TabControl.SelectedIndex</code> value to what I want when a button is pressed.</li> </ul> <p>To get around this problem, I think I am just going to have to use buttons in the place of the Tab Selectors (making them invisible) and just change the pages programmatically. This isn't a big deal, but I would just like to know if anyone else has encountered this problem, and maybe has an explanation for it!</p> <p>p.s. I'm kinda new to WPF and C#.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload