Skip to content

[WebView2] Event DocumentTitleChanged has always null argument instead of the new Value #21473

Closed as not planned

Description

@DevTKSS

Current behavior 🐛

  • The Event OnDocumentTitleChanged is only available on the CoreWebView2 Property of the WebView2
  • The Arguments parameter of the Event does always return null

Expected behavior 🎯

If the Documenttitle did change, we should be getting the new Value through the provided Argument, otherwhise it shouldnt be raised at all

How to reproduce it (as minimally and precisely as possible) 🔬

  • create a new Uno App with xaml markup and mvux (should be same in mvvm)
  • Add the WebView2 control in the xaml of the Page like this:
    <WebView2 x:Name="MyWebView2"
              Source="{Binding Path=CurrentUrl, Mode=TwoWay}" />
  • Register the CurrentUrl like this in your Model (or however you do the equivalent in Mvvm) or just hardcode it, should not make a difference.
    IState<Uri> CurrentUrl => State<Uri>.Value(this, () => new Uri("https://platform.uno/")
  • Register the EventHandler minimalistic in your codebehind of a Page:
            MyWebView2.CoreWebView2.DocumentTitleChanged += (s, e) =>
            {
                logger.LogInformation("Core Web View - DocumentTitleChanged, new Title as Object? Value: {Title}", e);
                
            };
    

You will always get null. I tryed for example to set it to the Content Property of my NavigationBar above the WebView2 control which got always null then.

Workaround 🛠️

we are needed to instead use the Value from the WebView2.CoreWebView2.DocumentTitle Property like this:

        MyWebView2.CoreWebView2.DocumentTitleChanged += (s, e) =>
        {
            logger.LogInformation("Core Web View - DocumentTitleChanged, new Title: {Title}", MyWebView2.CoreWebView2.DocumentTitle);
            MyNavigationBar.Content = MyWebView2.CoreWebView2.DocumentTitle;
        };

Renderer 🎨

  • Skia
  • Native

Affected platforms 📱💻🖥️

All platforms 🌍

Uno.Sdk version (and other relevant versions) 📦

Uno.Sdk: 6.2.36
Extension Version: 6.2.12.12

IDE version 🧑‍💻

Visual Studio 2022 17.14.13

Anything else we need to know? 💬

since we are able to get a DocumentTitle from the Property itself, this means we do generally know the Value we should be getting, but somewhere in the Call Stack its not provided consistently

Activity

  1. added
    triage/untriaged
    difficulty/tbd
    on Sep 13, 2025
  2. added theissue type on Sep 13, 2025
  3. added
    area/webview
    difficulty/starter 🚀
    and removed
    triage/untriaged
    difficulty/tbd
    on Oct 22, 2025
  4. morning4coffe-dev commented on Nov 25, 2025

    @morning4coffe-dev
    Member

    @DevTKSS I think this behavior is correct. I've looked into this, and the current behavior actually aligns with the underlying spec for WebView2.

    Why this is happening: The CoreWebView2.DocumentTitleChanged event is intentionally defined as an EventHandler. According to the Microsoft documentation and WinUI parity standards, the event argument is just a placeholder and is always null by design. It does not carry the new title string in the EventArgs.

    The Correct Pattern: The pattern you listed under "Workaround" is actually the intended usage pattern. The event is merely a notification trigger. To get the actual value, you must access the property directly within the handler, as the property is updated before the event is raised.

    // This is the correct/intended usage
    MyWebView2.CoreWebView2.DocumentTitleChanged += (s, e) =>
    {
        // 'e' is null by design; read the property instead
        var newTitle = MyWebView2.CoreWebView2.DocumentTitle;
        logger.LogInformation("New Title: {Title}", newTitle);
    };

    We can likely close this issue as "By Design" or "Not a Bug"

  5. github-actions commented on May 1, 2026

    @github-actions
    Contributor

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests.

  6. locked as resolved and limited conversation to collaborators on May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area/webviewdifficulty/starter 🚀

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions