Called when the page becomes the active content in the navigation frame.
Syntax
Visual Basic (Declaration) | |
---|
Protected Overridable Sub OnNavigatedTo( _
ByVal e As NavigationEventArgs _
) |
Parameters
- e
- An object that contains the event data.
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.
C# | Copy Code |
---|
// 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;
} |
Remarks
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also