Windows.UI.Xaml.Controls.WebView.NavigationStarting

August 15, 2022 ยท View on GitHub

-description

Occurs before the WebView navigates to new content.

-xaml-syntax

<WebView NavigationStarting="eventhandler" />

-remarks

You can cancel navigation in a handler for this event by setting the WebViewNavigationStartingEventArgs.Cancel property to true.

WebView navigation events occur in the following order:

Similar events occur in the same order for each iframe in the WebView content:

-examples

The following code example demonstrates how to handle this event to update a text box used as an address bar. For the complete example, see the XAML WebView control sample.

void webViewA_NavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)
{
    string url = "";
    try { url = args.Uri.ToString(); }
    finally
    {
        address.Text = url;
        appendLog(String.Format("Starting navigation to: \"{0}\".\n", url));
        pageIsLoading = true;
    }
}

-see-also

WebViewNavigationStartingEventArgs, XAML WebView control sample