Dela via


Frame.SourcePageType Property

Definition

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

public:
 property TypeName SourcePageType { TypeName get(); void set(TypeName value); };
TypeName SourcePageType();

void SourcePageType(TypeName value);
public System.Type SourcePageType { get; set; }
var typeName = frame.sourcePageType;
frame.sourcePageType = typeName;
Public Property SourcePageType As Type

Property Value

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 Microsoft 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.

Applies to

See also