如何在 WP7 中以编程方式设置选定的全景项目
我在 WP7 应用程序中使用全景控件。其中一个 PanoramaItems 将您带到另一个页面,然后您可以通过 EmailComposeTask 发送电子邮件。如果您没有选择发送电子邮件并按后退按钮,全景图将返回到您上次选择的项目。但是,如果您选择发送电子邮件(并因此离开应用程序),它不会返回到之前选择的 PanoramaItem。相反,它返回到全景图中的第一项。我尝试跟踪选定的索引并设置它,但收到一条错误消息,指出 SelectedIndex 不可设置。 MSDN 文档 http://msdn.microsoft.com/en-us/library/microsoft.phone.controls.panorama.selectedindex%28VS.92%29.aspx
有没有办法手动设置选定的索引/项目在全景图上?如果没有,是否有办法让它记住所选择的内容,即使用户离开应用程序来撰写电子邮件?
I'm using a panorama control in a WP7 app. One of the PanoramaItems takes you to another page, which then allows you send an email through the EmailComposeTask. If you don't select to send the email and press the back button, the Panorama returns to the item you last selected. However, if you do select to send an email (and therefore leave the app), it does not return to the previously selected PanoramaItem. Instead, it returns to the first item in the Panorama. I tried keeping track of the selected index and setting it, but I got an error saying the SelectedIndex is not settable. This is confirmed on MSDN documentation http://msdn.microsoft.com/en-us/library/microsoft.phone.controls.panorama.selectedindex%28VS.92%29.aspx
Is there any way to manually set the selected index/item on a panorama? If not, is there a way for it to remember what was selected, even if the user leaves the app to compose an email?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
当设备进入横向视图时,我使用此模型更改为枢轴,我可能最终会将当前项目提取到应用程序状态。全景图是横向方向的禁忌。
I'm using this model to change to a pivot when the device goes into landscape view, I'll probably end up extracting the current item to the application state. The panorama is a no-go in landscape orientation.
我不确定您是否可以以编程方式将动画强制到另一个
PanoramaItem
,但您可以更改 Panorama.DefaultItem。因此,您可能有 3 个
PanoramaItem
,并且在OnNavieratedTo()
处理程序上,通过以下方式更改默认项目:这在您从逻辑删除中恢复时应该会有所帮助。
I'm not sure if you can programmatically force an animation to another
PanoramaItem
, but you can change the Panorama.DefaultItem.So you might have 3
PanoramaItem
's and on theOnNavigatedTo()
handler, change the default item via:This should help when you recover from a tombstone.
您可以尝试 Silicon Shark 在该帖子中发布的解决方案。值得注意的是,它可以工作,但仅限于初始显示 - 这对于您在逻辑删除后恢复状态的要求来说应该不是问题。
如何以编程方式设置可见项目在全景控件中?
您可以从全景的 SelectedIndex 属性获取当前活动页面。
不幸的是,设置 DefualtItem 只是解决此问题的近似方法,您可能已经发现了这一点。
编辑:请注意,设置 DefaultItem 会更改全景图中的第一页。这是一个微妙的差异,但您会通过查看标题的位置和背景图像的环绕来了解它的重要性。
You could try the solution posted by Silicon Shark in this thread. It's noted to work, but only on the initial display - which shouldn't be a problem for your requirements of restoring state after tombstoning.
How to programmatically set the visible item in a Panorama control?
You can get the currently active page from the panorama's SelectedIndex property.
Unfortunately setting DefualtItem is only an approximation to solving this problem, which you may have discovered already.
Edit: Be aware that setting DefaultItem, changes which page of the panorama is the first page. It's a subtle difference, but you will see how it matters looking at the positioning of the heading and the wrap around of the background image.
这是一个解决方案。它确实按预期工作,并且不会重新排列您的全景图,因此您的用户界面是一致的。
这不是一个完美的解决方案,因为它不像全景图那样很好地滑动,而且可能不是很有效,但另一方面,您没有更改默认项目,因此您的用户界面保持一致。
Here is a solution. It does work as expected and does not rearrange your panorama, so your user interface is consistent.
this is not a perfect solution in that it does not slide nicely like panorama should, and it is probably not very efficient, but on the other hand you are not changing the default item so your user interface stays consistent.
我测试了此处列出的解决方案,但没有成功。这就是我所做的,这就像一个魅力!
您需要从列表中删除面板并将其重新插入到所需位置!
I tested solutions listed here without success. Here is what I did that works like a charm!
You need to remove the panel from the list and re-inserting it at the desired position!
设置新的所选项目但是
,它仅适用于初始项目,因此我的想法是当我们更改所选项目时让全景控件重新初始化。这是我的代码,只需在 Panorama.SelectedItem 更改后添加此代码即可。
但现在没有过渡效果!虽然,你可以创造你自己。
它对我来说非常有用,该页面还创建了向右滑动的效果 http: //xme.im/slide-or-change-panorama-selected-item-programatically
Set new selected item by
However, it work only on the initial so my idea is let the panorama control re-init when we change the selected item. This is my code, just add this after Panorama.SelectedItem changing.
But there is not transition effect now! Although, you can create your self.
It work great for me, this page also create a effect for sliding right http://xme.im/slide-or-change-panorama-selected-item-programatically