Windows Phone 7:恢复到选定的枢轴项目
当我在应用程序中使用Pivot
控件时,我想知道在用户逻辑删除应用程序后如何恢复到最后选定的枢轴项目(启动应用程序,按下Windows 按钮并按后退按钮恢复)?
(我尝试在 Application_Deactivated
和 Application_Deactivated
中添加一些代码,但没有成功)
As i'm using the Pivot
control in my app, I wonder how can I resume to the last selected pivot item after the user tombstoned the app (Launched the App, pressed the windows button and pressend the back button to resume)?
(I tried to add some code in the Application_Deactivated
and Application_Deactivated
but didn't work)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您跟踪数据透视表的
SelectedIndex
,则可以在从逻辑删除返回时恢复该值。以下是有关逻辑删除时保存数据的直接演练。
Win7 移动平台上的逻辑删除
If you keep track of your pivot's
SelectedIndex
, you can restore this value on return from tombstoning.Here's a straight forward walkthrough on saving data when tombstoned.
Tombstoning on the Win7 Mobile Platform
要实现逻辑删除,您确实需要向以下所有内容添加代码:
保存:
加载:
然后,您还需要覆盖数据透视表页面中的“OnNavigedTo” - 这是为数据透视表设置 SelectedIndex 的理想时间。
To implement tombstoning you really need to add code to all of:
Save:
Load:
Then you also need to override "OnNavigatedTo" within the Pivot Page - this is the ideal time to set the SelectedIndex for your pivot.
要保存数据透视表的状态,您应该在
OnNavieratedTo
和OnNavieratedFrom
方法中使用页面的State
属性。下面是一个基本示例: -
请注意,在您的应用程序被逻辑删除的情况下,Windows Phone 将处理此状态的持续存在。这种方法还使您的页面能够导航到应用程序中的其他位置,并在导航返回时恢复枢轴状态。
To save the state of the Pivot you should be using the
State
property of the page in theOnNavigatedTo
andOnNavigatedFrom
methods.Here is a basic example:-
Note that the Windows Phone will handle the persisting of this state in the case where your application gets tombstoned. This approach also enables your page to navigate to elsewhere in the app and on navigation back your pivot state is restored.