Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WP7: Get current PivotItem for data-bound Pivot

I have a Pivot, whose ItemsSource is set to a collection of data objects, and I use an ItemTemplate to transform the items into UI content (I also use a HeaderTemplate).

When tombstoning, I normally get the ScrollViewer from the current PivotItem and save the current position away, so that I can scroll back to the right position if the user navigates back to my app. This works fine if I hard-code the PivotItems in my XAML.

My issue is that the when the Pivot is bound to my data object collection using ItemsSource, SelectedItem returns one of my data objects - not the PivotItem. I can't see how to get to the current PivotItem (or the UI elements generated from my ItemTemplate). I've noticed protected members to go from a ItemsSource item to its corresponding container - perhaps I need to derive from Pivot to make use of these?

Thanks!

Damian

like image 505
Damian Avatar asked Mar 22 '26 20:03

Damian


1 Answers

Another way to get the Pivot item is described here - http://bea.stollnitz.com/blog/?p=7

Get a referenec to the Pivot control and you can then use Pivot.ItemContainerGenerator.ContainerFromIndex(index) tp get the PivotItem or you can use Pivot.ItemContainerGenerator.ContainerFromItem(dataobject)

like image 158
Ade A Avatar answered Mar 25 '26 13:03

Ade A



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!