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
Navigating
event that's raised when page navigation starts, and aNavigated
event that's raised when page navigation completes. TheWebNavigatingEventArgs
object that accompanies theNavigating
event defines aCancel
property of typebool
that can be used to cancel navigation. TheWebNavigatedEventArgs
object that accompanies theNavigated
event defines aResult
property of typeWebNavigationResult
that 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.