Frame.SourcePageType property

Applies to Windows and Windows Phone

Gets or sets a type reference of the current content, or the content that should be navigated to.

Syntax


public Type SourcePageType { get; set; }

Property value

Type: System.Type [.NET] | TypeName [C++]

A type reference for the current content, or the content to navigate to.

Remarks

CurrentSourcePageType and SourcePageType are normally the same value. However, if the frame calls Navigate and the navigation is still in progress, the CurrentSourcePageType is the value before the navigation and the SourcePageType is the value being navigated to.

Tip  If you are programming using a Microsoft .NET language (C# or 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 Visual Basic, use GetType.

SourcePageType can be set in XAML, using string-to-type conversion that's interpreted using XAML namespace mappings, but that's rarely done. It's a better practice to have code at the app level that tracks activation and whether a suspended app is resuming, which then uses Frame.Navigate to set the current page. The Visual Studio templates often produce such code for you. For this same reason, it's also rare to set SourcePageType as an alternative to calling Frame.Navigate, which also specifies a Page by type reference. If you do set a value for SourcePageType in XAML, you typically need to use a prefix such as "local:" that's defined in the same XAML construct. You need the prefix to map a XAML namespace that references the code namespace where your page partial class is defined. For more info, see XAML namespaces and namespace mapping.

A more typical scenario for SourcePageType in code is to only read its value, and not set it. For example you might compare SourcePageType for the current page in the Frame with items in the navigation stacks (BackStack, ForwardStack) to see if there are existing entries for that same Page.

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.Controls
Windows::UI::Xaml::Controls [C++]

Metadata

Windows.winmd

See also

Frame
Page
Frame.Navigate
CurrentSourcePageType
XAML Navigation sample

 

 

Show:
© 2014 Microsoft