C#Windows Store 8.1 GoBack方法 [英] C# Windows Store 8.1 GoBack method

查看:108
本文介绍了C#Windows Store 8.1 GoBack方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我创建了一个通用应用程序。在Windows 8.1项目中我有2页。

当我在MainPage中更改任何内容并按下GoForward按钮时,如此代码>



Frame.Navigate(typeof(Page2));



一切正常,但当我按下此代码按下按钮时,我有一个GoBack按钮:



MainPage.Current.GoBack();



主页上的所有内容我都会改变(就像一个新的开始)。

我该如何解决这个问题?

Hi,
I create a Universal apps. in Windows 8.1 Project i have 2 Pages.
when i changed anything in the MainPage and press the GoForward button like this code>

Frame.Navigate(typeof(Page2));

everything is working, but in the Page 2 i have a GoBack button when i pressed that button by this code:

MainPage.Current.GoBack();

everything in the MainPage i'v changed will be gone (like a fresh start).
how can i solve this problem?

推荐答案

据我所知,在Windows 8应用程序编程中,MainPage是默认的名称应用程序的页面,并且Page对象不包含当前的定义,您是否尝试将其用于 Window.Current 喜欢什么?所以错误在那里,那个属性来自哪里?看一下页面 [< a href =http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.page.aspxtarget =_ blanktitle =New Window> ^ ]课程并亲自看看。



但是,导航适用于页面的框架。您在哪里更改Frame对象的内容。



应用程序生命周期文档 [ ^ ]。我在2天前学习这个导航时还记得的另一件事是你需要启用页面的 NavigationCacheMode 属性。这将使您能够在内存中保留页面数据,并在加载页面时从内存中加载,而不是作为新页面加载。



所以你需要使用 Frame.Navigate(typeof(YourPage)); 可能Frame会被页面的框架对象替换,如果你使用默认代码(Visual Studio生成的代码),那么它被写成rootFrame。
As far as I know, in Windows 8 application programming, the MainPage is a name given to the default page of the application, and the Page object doesn't contain the definition for Current, did you try to use it for Window.Current like thing? So the error is there, where did that property come from? Have a look at the Page[^] class and see for yourself.

However, the navigation works for the Frames of the page. Where you change the content of the Frame object.

Application life cycle documentation[^]. One more thing that I recall while learning this navigation 2 days ago, was that you need to enable the NavigationCacheMode property of the page. Which will enable you to reserve the data of your page, inside the memory and upon loading the page would be loaded from the memory and not as a new page.

So you're required to use the Frame.Navigate(typeof(YourPage)); possibly the Frame would be replaced by the frame object of your page, if you're using the default code (code that Visual Studio generated) then it is written as rootFrame.


这篇关于C#Windows Store 8.1 GoBack方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆