Page..::.NavigationContext Property
.NET Framework Class Library for Silverlight
Page..::.NavigationContext Property

[Note: This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Gets an object that contains information about the navigation request.

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls.Navigation (in System.Windows.Controls.Navigation.dll)
Syntax

'Usage

Dim instance As Page
Dim value As NavigationContext

value = instance.NavigationContext


'Declaration

Public ReadOnly Property NavigationContext As NavigationContext
    Get

Property Value

Type: System.Windows.Navigation..::.NavigationContext
An object that contains information about the navigation request.
Remarks

When you retrieve an instance of the NavigationContext class through the NavigationContext property, you use the NavigationContext object to obtain information about the navigation request, such as the query string values and uniform resource identifier. You can use these values to generate the desired state of a page for a navigation request. For example, you may retrieve a query string value to determine which record from a data set to display.

Examples

The following example shows how to override the OnNavigatedTo method in a Silverlight page and obtain a query string value from the NavigationContext object. The query string value is used to determine which product is retrieved from a data service and displayed in the page.

Protected Overrides Sub OnNavigatedTo(ByVal e As System.Windows.Navigation.NavigationEventArgs)
    Dim productID As String
    Dim svcContext As DataServiceContext

    svcContext = New DataServiceContext(New Uri("AdventureWorks.svc", _
                UriKind.Relative))

    If (Me.NavigationContext.QueryString.ContainsKey("ProductId")) Then
        productID = Me.NavigationContext.QueryString("ProductId")
    Else
        productID = App.Current.Resources("FeaturedProductID").ToString()
    End If

    svcContext.BeginExecute(Of Product)(New Uri("Product(" + productID + ")", _
                UriKind.Relative), AddressOf loadProductCallback, svcContext)

End Sub

Private Sub loadProductCallback(ByVal asyncResult As IAsyncResult)
    Dim context As DataServiceContext
    context = asyncResult.AsyncState
    ListBox1.DataContext = context.EndExecute(Of Product)(asyncResult)
End Sub


Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference

Other Resources

© 2010 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View