As far as I know - ApplicationBar
associated with your Page
, but Pivot
is just a control on your Page
. So, ApplicationBar
is assigned for the entire Page
regardless of which Pivot
tab is shown.
You can do it by defining different application bars in resources section:
<phone:PhoneApplicationPage.Resources>
<shell:ApplicationBar x:Key="firstPivotTabApplicationBar" IsVisible="True">
...
</shell:ApplicationBar>
<shell:ApplicationBar x:Key="secondPivotTabApplicationBar" IsVisible="True">
...
</shell:ApplicationBar>
</phone:PhoneApplicationPage.Resources>
And processing SelectionChanged
event in your pivot control:
private void MainPagePivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
string pivotResource;
switch (_mainPagePivot.SelectedIndex)
{
case 0:
pivotResource = "firstPivotTabApplicationBar";
break;
case 1:
pivotResource = "secondPivotTabApplicationBar";
break;
default:
throw new ArgumentOutOfRangeException();
}
ApplicationBar = (ApplicationBar)Resources[pivotResource];
}