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...
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;
精彩评论