0

I'm looking for the WebView2 FrameNavigationCompleted Event in VB.NET. I couldn't find any examples. So far i have this:

 Async Sub InitializeAsync()
    Await MyWebView.EnsureCoreWebView2Async()

    AddHandler MyWebView.CoreWebView2.FrameNavigationCompleted, AddressOf MyWebView.FrameNavigationCompleted
End Sub

Private Sub MyWebView_FrameNavigationCompleted(sender As Object, e As CoreWebView2NavigationCompletedEventArgs)

End Sub

But it's giving me the error 'FrameNavigationCompleted' is not a member of 'WebView2'

Could someone please give me a full code example? Thanks!

Desz
  • 31
  • 7
  • Add in `Form.Load` - in any case after `await [WebView2].EnsureCoreWebView2Async();` -: `AddHandler [WebView2].CoreWebView2.FrameNavigationCompleted, AddressOf WebView2_FrameNavigationCompleted`. Remove `Handles CoreWebView21.FrameNavigationCompleted` from the event handler. -- Assuming WinForms and .Net Framework 4.8, you need to Tag your Question to specify the Platform and add other relevant information on your app. – Jimi Feb 20 '21 at 15:51
  • Thank you for your comment! i now have this: `Async Sub InitializeAsync() Await WebView2.EnsureCoreWebView2Async() AddHandler WebView2.CoreWebView2.FrameNavigationCompleted, AddressOf WebView2.FrameNavigationCompleted End Sub` `Private Sub WebView2_FrameNavigationCompleted(sender As Object, e As CoreWebView2NavigationCompletedEventArgs) End Sub` But i get an error: 'FrameNavigationCompleted' is not a member of 'WebView2'. – Desz Feb 20 '21 at 16:12
  • You didn't add the required Tags to the question. -- `[WebView2]` means *the Instance of WebView2 as declared in your application*. This instance should not be named `WebView2` (assuming this is the actual instance name you're using). If you haven't, you need to create an Instance of the WebView2 object -- Don't post updates to the question in comments, [Edit](https://stackoverflow.com/posts/66293369/edit) your question instead. – Jimi Feb 20 '21 at 16:16
  • i've added the tags to my question, my WebView2 control was named WebView2. I now changed the name but the error remains: 'FrameNavigationCompleted' is not a member of 'WebView2'. sorry this is my first question here on stackoverflow. – Desz Feb 20 '21 at 16:26
  • 1
    It's not `... AddressOf WebView2.FrameNavigationCompleted`, but `AddressOf WebView2_FrameNavigationCompleted`. Do you have `Option Strict On`? If not, set it `On` before anything else. -- You didn't update your question: move that code you posted in a comment to the body of your question, remove the comment after. Add all the details (and code) needed to make clear when and where this code is used or called. -- You skipped [the Tour](https://stackoverflow.com/tour): you need to go to the [Help Center](https://stackoverflow.com/help) and read about asking questions here. – Jimi Feb 20 '21 at 16:48

0 Answers0