Paging Overview

Rico Suter edited this page Jul 8, 2015 · 5 revisions
  • Package: MyToolkit.Extended
  • Platforms: WP7SL, WP8SL, WinRT, UWP

Improved paging classes for Universal Windows Apps and Windows Phone Silverlight apps.

WinRT and UWP

For Universal Windows Apps (UWP) and Windows Phone Apps

The Page, Frame, SuspensionManager and other classes have been reimplemented to avoid the annoying page caching problem (see this StackOverflow Question) and to add more features - for example asynchronous navigation methods.

The idea was to completely replace the original Frame and Page class usages through the new implementations. The replacement classes provide the exact same functionality plus more advanced features which help build more robust apps.

Check out the following classes for more information about the new features:


There are two ways to replace the original initialization of the frame object with the new logic for instantiating an MtFrame:

  • (Recommended) Replace the Application class with MtApplication: Completely replace the application class so that the MtApplication class can hook into the appropriate events and abstract away all logic to create the root frame.
  • Replace the Frame class with MtFrame: Only replace the instantiation of the frame object through the new code.

In both cases, all pages have to inherit from the MtPage class instead of the original page class and all usages of the NavigationHelper class must be replaced with the MtNavigationHelper class:


(Recommended) Replace the Application class with MtApplication

Open your App.xaml and replace the Application class with the MtApplication class:


In the application's code-behind, implement the abstract member StartPageType and override OnInitializedAsync if needed:

public sealed partial class App
    public App()

        if (System.Diagnostics.Debugger.IsAttached)
            DebugSettings.EnableFrameRateCounter = true;

    public override Type StartPageType
        get { return typeof(MainPage); }

    public override Task OnInitializedAsync(MtFrame frame, ApplicationExecutionState e)
        // TODO: Called when the app is started (not resumed)
        return null;

Full sample: App.xaml.cs

Replace the Frame class with MtFrame

To use the new paging classes without changing the application class, perform the following steps:

protected override async void OnLaunched(LaunchActivatedEventArgs args)
	var rootFrame = Window.Current.Content as MtFrame;
	if (rootFrame == null)
		rootFrame = new MtFrame();
		MtSuspensionManager.RegisterFrame(rootFrame, "AppFrame");
		if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
				await MtSuspensionManager.RestoreAsync();
			catch { }
		Window.Current.Content = rootFrame;
		// TODO initialize application (same as OnInitializedAsync above)
	if (rootFrame.Content == null)
		if (# rootFrame.Initialize(typeof(MainPage)))
			throw new Exception("Failed to create initial page");

private async void OnSuspending(object sender, SuspendingEventArgs e)
    var deferral = e.SuspendingOperation.GetDeferral();
    await MtSuspensionManager.SaveAsync();

Issues / known problems

Do not add NavigationThemeTransition to ContentTransitions of MtFrame as it is not supported. Use the PageAnimation property of MtFrame for page transition animations. Adding NavigationThemeTransition causes a "Invalid pointer" exception on application start.

Windows Phone Silverlight

Improved and added overridable life cycle methods and page animations.