MicrosoftEdge / MicrosoftEdge/WebView2Feedback
How to focus WebView2 in TabControl
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
I've an application with tabs and in each tab there can be a WebView2 instance. In the WebView2 component of the active tab any random html input element can be currently focused. When i switch between tabs in the TabControl as a user I expect the focus to return to the html element that was previously focused for that tab.
I've made a quick example to show my problem:
https://github.com/frankdekker/WebView2RequestFocusExample

- Place the cursor in the input field of the search engine
- Switch to the second tab
- Switch back to the first tab
- I expect the WebView2 to be focused and my cursor be active in the input field
In MainWindow.xaml.cs you can see I request focus to the WebView2 of that tab.
I'm not quite sure what I should do differently. How should I get the WebView2 focused again?
Thanks in advance. Loving WebView2 so far :)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked WebView2RequestFocusExample, especially MainWindow.xaml.cs and its TabControl selection or focus handling. Reproduce the four listed steps, then inspect the WebView2 focus lifecycle and relevant WebView2 API documentation. Done means the active tab reliably restores the previously focused HTML input, with the behavior demonstrated by the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100