views:

135

answers:

0

We have a WinForms window with a WebBrowser control in it, pointing to a page with a Silverlight 3 control on it. If a Silverlight control has focus and you Alt+Tab away and back again, the focus is gone. Strangely, if you do the same thing again, focus returns to where it was.

I’ve tried to manually re-focus the Silverlight control after coming back from the Alt+Tab, but it doesn’t seem to work:

this.Activated += delegate
{
    this.webBrowser1.Document.ActiveElement.Focus();
};

The delegate fires each time you Alt+Tab back, and it works for normal HTML pages. In my case it’s calling Focus() on the Silverlight control, but GotFocus is not firing within the Silverlight application. Also in our implementation we can’t explicitly communicate with elements inside the page; the browser shell is generic.

Anyone have any ideas for getting around this and returning focus on coming back from Alt+Tab?