Mike
Mike

Reputation: 11

WPF XAML Web Browser in Tab Item issue

I am developing an application that involves a web browser object in a tab item of a tab control.

example:

<Window x:Class="TabControl.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
<Grid>
    <TabControl
            x:Name="tabControl1">
        <TabItem>
            <TextBox>Hello</TextBox>
        </TabItem>
        <TabItem>
            <WebBrowser Source="http://www.google.com"></WebBrowser>
        </TabItem>
    </TabControl>
</Grid>

So, the first time you click on the web browser tab, the focus goes to the search box in google, when you try to go back to the first tab, it requires two clicks, one i assume to take the focus away from the webpage, and another to move the selected tab item? Can anyone offer a suggestion that would enable the tab to be changed with only one click? Cheers!

Upvotes: 1

Views: 1698

Answers (1)

bronkman
bronkman

Reputation: 21

Add a PreviewMouseLeftButtonDown handler for tabControl1 and set tabControl1 to focus.

Upvotes: 2

Related Questions