Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programmatically set selected Panorama item in WP7

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?

like image 564
CACuzcatlan Avatar asked Jan 07 '11 03:01

CACuzcatlan


1 Answers

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 the OnNavigatedTo() handler, change the default item via:

panoramaControl.DefaultItem = panoramaControl.Items[indexToSet];

This should help when you recover from a tombstone.

like image 176
Alastair Pitts Avatar answered Oct 20 '22 03:10

Alastair Pitts