我需要在cs代码中切换Pivots,它适用于手动索引:
MyPivot.SelectedIndex = 3;
但这样的事情对我来说会好得多:
MyPivot.SelectedIndex = targetPivotItem.Index;
但我找不到任何财产......
答案 0 :(得分:4)
如果您未在ItemsSource
上使用Pivot
。
Pivot1.SelectedIndex = Pivot1.Items.IndexOf(PivotItem1);
如果您已将Pivot
的ItemsSource设置为集合,请使用以下代码:
Pivot1.SelectedItem = PivotItem1.DataContext;