Hello,
Maui Webview provides two navigation events to handle events during and after a page navigating.
You could refer to the official documentation and sample code below.
WebView defines a
Navigatingevent that's raised when page navigation starts, and aNavigatedevent that's raised when page navigation completes. TheWebNavigatingEventArgsobject that accompanies theNavigatingevent defines aCancelproperty of typeboolthat can be used to cancel navigation. TheWebNavigatedEventArgsobject that accompanies theNavigatedevent defines aResultproperty of typeWebNavigationResultthat indicates the navigation result.
// in xaml
<WebView Source="
https://cn.bing.com/"
WidthRequest="200" HeightRequest="300"
Navigating="WebView_Navigating" Navigated="WebView_Navigated"/>
// in code-behind
private void WebView_Navigating(object sender, WebNavigatingEventArgs e)
{
Console.WriteLine(e.Url);
}
private void WebView_Navigated(object sender, WebNavigatedEventArgs e)
{
Console.WriteLine(e.Url);
}
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.