Reputation: 31313
What methods can I use to detect which PivotItem is clicked by the user? This is in a Win10 environment and all users have mouse/keyboard.
<Pivot x:Name="settingsPivot" SelectedIndex="{x:Bind ViewModel.PivotSelectedIndex, Mode=TwoWay}">
<PivotItem Header="General">
</PivotItem>
<PivotItem Header="Properties">
</PivotItem>
<PivotItem Header="Purchasers">
</PivotItem>
</Pivot>
And I can get the SelectedIndex, but I don't want to rely on ordinal position to determine what action I should take.
Upvotes: 0
Views: 95
Reputation: 859
You can use the SelectionChanged
event of the pivot:
private void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0)
{
PivotItem selected = e.AddedItems[0] as PivotItem;
Debug.WriteLine("selected pivotitem: " + selected.Header);
}
}
Upvotes: 1