Improved paging classes for Universal Windows Apps and Windows Phone Silverlight apps.
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:
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:
<paging:MtPage x:Class="MyPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:Rezeptewiki.Views" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:paging="using:MyToolkit.Paging" mc:Ignorable="d"> ... </paging:MtPage>
(Recommended) Replace the Application class with MtApplication
Open your App.xaml and replace the Application class with the MtApplication class:
<paging:MtApplication x:Class="MyApp.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:paging="using:MyToolkit.Paging"> ... </paging:MtApplication>
In the application's code-behind, implement the abstract member StartPageType and override OnInitializedAsync if needed:
public sealed partial class App { public App() { InitializeComponent(); #if DEBUG if (System.Diagnostics.Debugger.IsAttached) DebugSettings.EnableFrameRateCounter = true; #endif } 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) { try { 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"); } Window.Current.Activate(); } private async void OnSuspending(object sender, SuspendingEventArgs e) { var deferral = e.SuspendingOperation.GetDeferral(); await MtSuspensionManager.SaveAsync(); deferral.Complete(); }
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 SilverlightImproved and added overridable life cycle methods and page animations.
Classes:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4