Janci
Janci

Reputation: 863

WP7 PivotItem switch index

I need to switch Pivots in cs code, It works with manual indexes:

MyPivot.SelectedIndex = 3;  

But something like this will be much better for me:

MyPivot.SelectedIndex = targetPivotItem.Index; 

but I couldn't found any property for that...

Upvotes: 1

Views: 1568

Answers (1)

decyclone
decyclone

Reputation: 30830

This is if you are not using ItemsSource on your Pivot.

Pivot1.SelectedIndex = Pivot1.Items.IndexOf(PivotItem1);

If you have set your Pivot's ItemsSource to a collection, use following code:

Pivot1.SelectedItem = PivotItem1.DataContext;

Upvotes: 4

Related Questions