Intersoft ClientUI Documentation
OnNavigatedTo(NavigationEventArgs) Method
Example 



An object that contains the event data.
Called when the page becomes the active content in the navigation frame.
Syntax
Protected Overridable Sub OnNavigatedTo( _
   ByVal e As NavigationEventArgs _
) 
Dim instance As UXPage
Dim e As NavigationEventArgs
 
instance.OnNavigatedTo(e)
protected virtual void OnNavigatedTo( 
   NavigationEventArgs e
)
protected:
virtual void OnNavigatedTo( 
   NavigationEventArgs^ e
) 

Parameters

e
An object that contains the event data.
Remarks

You override the OnNavigatedTo method to examine the navigation request and prepare the page for display. For example, you can load the requested data and enable or disable visual elements.

Typically, you use the OnNavigatedTo method instead of creating an event handler for the Loaded event. The OnNavigatedTo method is preferable because it is only called once for each time the page becomes active. The Silverlight framework raises the Loaded event each time the element is added to the visual tree, which potentially can happen more than once when activating a page.

The OnNavigatedTo method is called for each request, even when the page is retrieved from the cache. You should include in this method code that must be executed for each request rather than placing that code in the UXPage constructor.

Example

The following example shows how to override the OnNavigatedTo method to obtain the query string that passed from the navigation context, set the data context and display the data accordingly.

// Executes when the user navigates to this page.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
    if (this.NavigationContext.QueryString.Count > 0)
    {
        string customerID = this.NavigationContext.QueryString["ID"];

        if (!string.IsNullOrEmpty(customerID))
        {
            // Binds the view model to data context
            // The view model loads the selected contact based on 
            // the data passed in the QueryString.
            this.DataContext = new ContactDetailsViewModel((ContactsViewModel)this.DataContext, customerID);

            // hide info label
            InfoLabel.Visibility = Visibility.Collapsed;

            return;
        }
    }

    // hide details panel
    DetailsPanel.Visibility = Visibility.Collapsed;
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

UXPage Class
UXPage Members

Send Feedback