LoadCompletedEventHandler delegate

Applies to Windows and Windows Phone

[LoadCompleted may be altered or unavailable for releases after Windows 8.1. Instead, use NavigationCompleted.]

Represents the method that will handle the LoadCompleted event.

Syntax


public delegate void LoadCompletedEventHandler(
  object sender, 
  NavigationEventArgs e
)

Attributes

[Version(0x06020000)]
[WebHostHidden()]

Parameters

sender

Type: System.Object [.NET] | Platform::Object [C++]

The source of the event.

e

Type: NavigationEventArgs

The event data.

Examples

The following example code demonstrates the use of this type. For the complete code listing, see the XAML WebView control sample.


private void NavigateButton_Click(object sender, RoutedEventArgs e)
{
    ProgressRing1.IsActive = true;

    // Provide an indication as to where we are trying to navigate to
    rootPage.NotifyUser(String.Format("Navigating to: {0}", Address.Text), NotifyType.StatusMessage);

    // Hook the LoadCompleted event for the WebView to know when the URL is fully loaded
    WebView1.LoadCompleted += new Windows.UI.Xaml.Navigation.LoadCompletedEventHandler(WebView1_LoadCompleted);

    // Attempt to navigate to the specified URL.  Notice that a malformed URL will raise a FormatException
    // which we catch and let the user know that the URL is bad and to enter a new well-formed one.
    try
    {
        Uri targetUri = new Uri(Address.Text);
        WebView1.Navigate(targetUri);
    }
    catch (FormatException myE)
    {
        // Bad address
        rootPage.NotifyUser(String.Format("Address is invalid, try again.  Details --> {0}", myE.Message), NotifyType.ErrorMessage);
    }
}

void WebView1_LoadCompleted(object sender, Windows.UI.Xaml.Navigation.NavigationEventArgs e)
{
    WebView1.Visibility = Windows.UI.Xaml.Visibility.Visible;
    BlockingRect.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
    ProgressRing1.IsActive = false;

    // Tell the user that the page has loaded
    rootPage.NotifyUser("Page loaded", NotifyType.StatusMessage);
}

void Address_KeyUp(object sender, KeyRoutedEventArgs e)
{
    if (e.Key == Windows.System.VirtualKey.Enter)
    {
        NavigateButton_Click(this, new RoutedEventArgs());
    }
}


Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Navigation
Windows::UI::Xaml::Navigation [C++]

Metadata

Windows.winmd

See also

WebView
XAML WebView control sample

 

 

Show:
© 2014 Microsoft