关于为Pivot不同的PivotItem定制ApplicationBa,原理其实很简单,首先定义多套ApplicationBar资源
<shell:ApplicationBar x:Key="appbar1" IsVisible="True">
<shell:ApplicationBarIconButton IconUri="Images/appbar.add.rest.png" Text="Button1_1"/>
<shell:ApplicationBarIconButton IconUri="Images/appbar.back.rest.png" Text="Button1_2"/>
</shell:ApplicationBar>
<shell:ApplicationBar x:Key="appbar2" IsVisible="True">
<shell:ApplicationBarIconButton IconUri="Images/appbar.delete.rest.png" Text="Button2_1"/>
<shell:ApplicationBarIconButton IconUri="Images/appbar.next.rest.png" Text="Button2_2"/>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.Resources>
还可以为不同的Button设置响应事件,这里就略去了。
其次,让Pivot
control响应SelectionChanged事件
事件处理函数中为不同的PivotItem设置不同的ApplicationBar
{
if (MyPivotControl.SelectedIndex == 0)
ApplicationBar = (Microsoft.Phone.Shell.ApplicationBar)Resources["appbar1"];
else if (MyPivotControl.SelectedIndex == 1)
ApplicationBar = (Microsoft.Phone.Shell.ApplicationBar)Resources["appbar2"];
}
http://www.hugwp.com/article-750-1.html