Document window tab color doesn't change to active color

Docking/MDI for WPF Forum

Posted 2 years ago by Yuki
Version: 22.1.2
Avatar

Hello,

In our application,  WebView2 is placed in document window.

When I put 2 document windows side by side and click the window content(WebView2 area), document window tab color doesn't change to active color(blue).

Would you please help us?

Please change the following file, you can reproduce it.

File: SampleBrowser\ProductSamples\DockingSamples\QuickStart\MvvmDocumentWindows\TextDocumentItemView.xaml

<UserControl
    x:Class="ActiproSoftware.ProductSamples.DockingSamples.QuickStart.MvvmDocumentWindows.TextDocumentItemView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking"
    xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <TextBox Grid.Row="0" BorderThickness="0" Text="{Binding Path=Text, Mode=TwoWay}" TextWrapping="Wrap" />
        <wv2:WebView2 x:Name="WV2" Grid.Row="1" docking:InteropFocusTracking.IsEnabled="True" Source="https://www.actiprosoftware.com/blog" />
    </Grid>
</UserControl>

Comments (5)

Answer - Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

WebView2 seems to handle some of their WPF-related focus handling in a different thread.  IKeyboardInputSink.HasFocusWithin calls to it, even in GotFocus handlers, don't reliably always return true immediately.  That is what led to this particular issue.

We've been able to add a workaround for the next maintenance release that should help with this problem.  If you'd like to test a preview build containing our code updates, please write our support address and mention this thread.


Actipro Software Support

Posted 2 years ago by Yuki
Avatar

Hello,

I confirmed the issue is solved in preview build version. (22.1.3-beta.6)

Thank you for your support.

Posted 2 years ago by Yuki
Avatar

Hello,

I've found minor issue regarding active window when I use context menu of WebView2.

I'm not sure if it is caused by ActiproSoftware library or not.

Would you please check it?

  1. Customize context menu in WebView2
    Customize context menus in WebView2 - Microsoft Edge Development | Microsoft Docs
  2. Put 2 document windows contains WebView2 side by side
  3. Click right mouse button on first document window
    --> Context menu will be shown.
  4. Click left mouse button on second document window
    --> Context menu is closed, but active window is still first window
  5. Click left mouse button again on second window
    --> Second window become active
Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

I tried this and think it's a bug with Edge's implementation of the custom menu. 

First, if you don't do the #1 (customize context menu) step, it seems to work fine. 

If you do the customize context menu, show the context menu and click in any control other than another WebView2, focus moves.  If you click on another WebView2 while the context menu is shown, focus does not move. 

For instance if you have focus in a search textbox within a browser page, show the context menu, and then click into a search textbox within the other browser's page, you'll see focus doesn't move on first click.  It does move on second click so this makes me think it's some sort of mouse capture issue on their end.

If you use your XAML code above, you can see how showing the context menu and clicking on a WPF TextBox outside of the browser works fine to move focus.


Actipro Software Support

Posted 2 years ago by Yuki
Avatar

Hello,

Thank you for checking.

I'm going to check WebView2 more.

The latest build of this product (v24.1.2) was released 2 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.