locked
How to wait in function till WebView.NavigateToString completes RRS feed

  • Question

  • Hi,

    I am writing a Windows Store App on C#. I have a function where I call webView.NavigateToString(html) and then after it loads I want to do some code in that function. How can I iplement that? Code That will be executed depends on what will be drawn in WebView.

    private void MyFunction()

    {

    ...

    webView.NavigateToString(html)

    //After it loads do some code

    some code here

    ...

    }

    Sunday, February 10, 2013 12:20 PM

Answers

  •         private void Button_Click_1(object sender, RoutedEventArgs e)
            {
                myWebView.LoadCompleted += wv1_LoadCompleted;
                myWebView.NavigateToString(
                    "<html><head></head><body>Silverlight Developer Site" +
                    "<iframe src=\"http://www.silverlight.net\" WIDTH=300 HEIGHT=200>" +
                    "</iframe></body></html>");
            }
            void wv1_LoadCompleted(object sender, NavigationEventArgs e)
            {
                myWebView.LoadCompleted -= wv1_LoadCompleted;
                Debug.WriteLine("wv1_LoadCompleted");
            }
    

    The above LoadCompleted event might fit your scenario.

    • Marked as answer by KotominN Wednesday, February 13, 2013 10:11 AM
    Sunday, February 10, 2013 1:07 PM