Reputation: 863
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
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