本文整理汇总了C#中PhoneApplicationFrame.RemoveBackEntry方法的典型用法代码示例。如果您正苦于以下问题:C# PhoneApplicationFrame.RemoveBackEntry方法的具体用法?C# PhoneApplicationFrame.RemoveBackEntry怎么用?C# PhoneApplicationFrame.RemoveBackEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhoneApplicationFrame
的用法示例。
在下文中一共展示了PhoneApplicationFrame.RemoveBackEntry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PurgeNavigationalBackstack
/// <summary>
/// Purges the Root Frame off all Navigational Journal Entries. This
/// has the effect of causing you app to exit if the back button is
/// pressed after this method is called.
/// </summary>
/// <param name="rootFrame"></param>
public static void PurgeNavigationalBackstack(PhoneApplicationFrame rootFrame)
{
var purgeList = new System.Collections.Generic.List<System.Windows.Navigation.JournalEntry>();
foreach (var entry in rootFrame.BackStack)
purgeList.Add(entry);
foreach (var entry in purgeList)
{
if (rootFrame.CanGoBack)
rootFrame.RemoveBackEntry();
}
}
示例2: AutoSuspendApplication
protected AutoSuspendApplication()
{
var host = new SuspensionHost();
host.IsLaunchingNew =
Observable.FromEventPattern<LaunchingEventArgs>(
x => PhoneApplicationService.Current.Launching += x, x => PhoneApplicationService.Current.Launching -= x)
.Select(_ => Unit.Default);
host.IsUnpausing =
Observable.FromEventPattern<ActivatedEventArgs>(
x => PhoneApplicationService.Current.Activated += x, x => PhoneApplicationService.Current.Activated -= x)
.Where(x => x.EventArgs.IsApplicationInstancePreserved)
.Select(_ => Unit.Default);
// NB: "Applications should not perform resource-intensive tasks
// such as loading from isolated storage or a network resource
// during the Activated event handler because it increase the time
// it takes for the application to resume"
host.IsResuming =
Observable.FromEventPattern<ActivatedEventArgs>(
x => PhoneApplicationService.Current.Activated += x, x => PhoneApplicationService.Current.Activated -= x)
.Where(x => !x.EventArgs.IsApplicationInstancePreserved)
.Select(_ => Unit.Default)
.ObserveOn(RxApp.TaskpoolScheduler);
// NB: No way to tell OS that we need time to suspend, we have to
// do it in-process
host.ShouldPersistState = Observable.Merge(
Observable.FromEventPattern<DeactivatedEventArgs>(
x => PhoneApplicationService.Current.Deactivated += x, x => PhoneApplicationService.Current.Deactivated -= x)
.Select(_ => Disposable.Empty),
Observable.FromEventPattern<ClosingEventArgs>(
x => PhoneApplicationService.Current.Closing += x, x => PhoneApplicationService.Current.Closing -= x)
.Select(_ => Disposable.Empty));
host.ShouldInvalidateState =
Observable.FromEventPattern<ApplicationUnhandledExceptionEventArgs>(x => UnhandledException += x, x => UnhandledException -= x)
.Select(_ => Unit.Default);
SuspensionHost = host;
//
// Do the equivalent steps that the boilerplate code does for WP8 apps
//
if (RootFrame != null) return;
RootFrame = new PhoneApplicationFrame();
var currentBackHook = default(IDisposable);
var currentViewFor = default(WeakReference<IViewFor>);
RootFrame.Navigated += (o, e) => {
// Always clear the WP8 Back Stack, we're using our own
while (RootFrame.RemoveBackEntry() != null) {}
if (currentBackHook != null) currentBackHook.Dispose();
var page = RootFrame.Content as PhoneApplicationPage;
if (page != null) {
currentBackHook = Observable.FromEventPattern<CancelEventArgs>(x => page.BackKeyPress += x, x => page.BackKeyPress -= x)
.Where(_ => ViewModel != null)
.Subscribe(x => {
if (!ViewModel.Router.NavigateBack.CanExecute(null)) return;
x.EventArgs.Cancel = true;
ViewModel.Router.NavigateBack.Execute(null);
});
var viewFor = page as IViewFor;
if (viewFor == null) {
throw new Exception("Your Main Page (i.e. the one that is pointed to by WMAppManifest) must implement IViewFor<YourAppBootstrapperClass>");
}
currentViewFor = new WeakReference<IViewFor>(viewFor);
viewFor.ViewModel = ViewModel;
}
// Finally make it live
RootVisual = RootFrame;
};
_viewModelChanged.StartWith(ViewModel).Where(x => x != null).Subscribe(vm => {
var viewFor = default(IViewFor);
if (currentViewFor != null && currentViewFor.TryGetTarget(out viewFor)) {
viewFor.ViewModel = vm;
}
});
UnhandledException += (o, e) => {
if (Debugger.IsAttached) Debugger.Break();
};
RootFrame.NavigationFailed += (o, e) => {
if (Debugger.IsAttached) Debugger.Break();
};
}