一、在xaml页面定义两个ApplicationBar:
<phone:PhoneApplicationPage.Resources><shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" x:Key="appBar0" Mode="Default">
<shell:ApplicationBarIconButton Text="appBarBtn0" IconUri="appBarBtn0.png" Click="appBarBtn0_Click"/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="appBarMenu0" Click="appBarMenu0_Click"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar><shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" x:Key="appBar1" Mode="Default">
<shell:ApplicationBarIconButton Text="appBarBtn1" IconUri="appBarBtn1.png" Click="appBarBtn1_Click"/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="appBarMenu1" Click="appBarMenu1_Click"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar></phone:PhoneApplicationPage.Resources>
二、在cs代码中事件函数中加入一下代码(这里以panorama为例子):
#region panorama不同item显示不同applicationbar
private void panoramaPage_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
switch (((Panorama)sender).SelectedIndex)
{
case 0:
ApplicationBar = (ApplicationBar)this.Resources["appBar0"];
break;
case 1:
ApplicationBar = (ApplicationBar)this.Resources["appBar1"];
break;
}
}
#endregion