Frame.Navigate Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
Navigate(TypeName) |
Causes the Frame to load content represented by the specified Page. |
Navigate(TypeName, Object) |
Causes the Frame to load content represented by the specified Page, also passing a parameter to be interpreted by the target of the navigation. |
Navigate(TypeName, Object, NavigationTransitionInfo) |
Causes the Frame to load content represented by the specified Page-derived data type, also passing a parameter to be interpreted by the target of the navigation, and a value indicating the animated transition to use. |
Navigate(TypeName)
public:
virtual bool Navigate(TypeName sourcePageType) = Navigate;
bool Navigate(TypeName const& sourcePageType);
public bool Navigate(System.Type sourcePageType);
function navigate(sourcePageType)
Public Function Navigate (sourcePageType As Type) As Boolean
Parameters
The page to navigate to, specified as a type reference to its partial class type. (A type reference is given as System.Type for Microsoft .NET, or a TypeName helper struct for C++).
Returns
bool
false
if a NavigationFailed event handler has set Handled to true
; otherwise, true
. See Remarks for more info.
Implements
Applies to
Navigate(TypeName, Object)
public:
virtual bool Navigate(TypeName sourcePageType, Platform::Object ^ parameter) = Navigate;
/// [Windows.Foundation.Metadata.Overload("Navigate")]
bool Navigate(TypeName const& sourcePageType, IInspectable const& parameter);
[Windows.Foundation.Metadata.Overload("Navigate")]
public bool Navigate(System.Type sourcePageType, object parameter);
function navigate(sourcePageType, parameter)
Public Function Navigate (sourcePageType As Type, parameter As Object) As Boolean
Parameters
The page to navigate to, specified as a type reference to its partial class type. (A type reference is given as System.Type for Microsoft .NET, or a TypeName helper struct for C++).
- parameter
-
Object
Platform::Object
IInspectable
The navigation parameter to pass to the target page.
Returns
bool
false
if a NavigationFailed event handler has set Handled to true
; otherwise, true
. See Remarks for more info.
- Attributes
Applies to
Navigate(TypeName, Object, NavigationTransitionInfo)
public:
virtual bool Navigate(TypeName sourcePageType, Platform::Object ^ parameter, NavigationTransitionInfo ^ infoOverride) = Navigate;
/// [Windows.Foundation.Metadata.Overload("NavigateWithTransitionInfo")]
bool Navigate(TypeName const& sourcePageType, IInspectable const& parameter, NavigationTransitionInfo const& infoOverride);
[Windows.Foundation.Metadata.Overload("NavigateWithTransitionInfo")]
public bool Navigate(System.Type sourcePageType, object parameter, NavigationTransitionInfo infoOverride);
function navigate(sourcePageType, parameter, infoOverride)
Public Function Navigate (sourcePageType As Type, parameter As Object, infoOverride As NavigationTransitionInfo) As Boolean
Parameters
The page to navigate to, specified as a type reference to its partial class type. (A type reference is given as System.Type for Microsoft .NET, or a TypeName helper struct for C++).
- parameter
-
Object
Platform::Object
IInspectable
The navigation parameter to pass to the target page; must have a basic type (string, char, numeric, or GUID) to support parameter serialization using GetNavigationState.
- infoOverride
- NavigationTransitionInfo
Info about the animated transition.
Returns
bool
false
if a NavigationFailed event handler has set Handled to true
; otherwise, true
. See Remarks for more info.
- Attributes
Examples
<Frame x:Name="myFrame">
<Frame.ContentTransitions>
<TransitionCollection>
<NavigationThemeTransition />
</TransitionCollection>
</Frame.ContentTransitions>
</Frame>
// Play the default animation
myFrame.Navigate(typeof(Page2), null);
// Explicitly play the page refresh animation
myFrame.Navigate(typeof(Page2), null, new EntranceNavigationTransitionInfo());
// Play the drill in animation
myFrame.Navigate(typeof(Page2), null, new DrillInNavigationTransitionInfo());
// Suppress the default animation
myFrame.Navigate(typeof(Page2), null, new SuppressNavigationTransitionInfo());
Remarks
You handle the NavigationFailed event to respond to navigation failure. You can handle the failure directly in the event handler, or you can set the NavigationFailedEventArgs.Handled property to true
and use the Navigate method return value to respond to the failure.
Parameter values
You can use GetNavigationState to serialize the frame's state, and SetNavigationState to restore it later. To enable frame state serialization using these methods, you must use only basic types for the navigation parameter
, such as string, char, numeric, and GUID types. Otherwise, GetNavigationState
will throw an exception.
The parameter
value can have a complex type if you do not use GetNavigationState. However, you should still use only basic types in order to avoid excess memory usage caused by the frame’s navigation stack holding a reference to the parameter
. A preferred approach is to not pass the actual object, but instead pass an identifier that you can use to look up the object in the target landing page. For example, instead of passing a Customer
object, pass a reference to the CustomerID
, then look up the Customer
after the navigation is complete.
Tip
If you are programming using a Microsoft .NET language (C# or Microsoft Visual Basic), the TypeName type projects as System.Type. When programming using C#, it is common to use the typeof
operator to get references to the System.Type of a type. In Microsoft Visual Basic, use GetType
. If you're using C++/WinRT you can use the winrt::xaml_typename<T>()
helper function to create a TypeName
object. See winrt::xaml_typename function template for more details, and a code example.