In this code snippet , you will see how to use different app bar in windows phone 8/8.1 Silverlight App,suppose you need to show different ApplicationBar when User Swipes Pivot.So to do this.
Creat App bar's in XAML Page(Paste it From Below Code Snippet).
Important:Add/Remove Click Events and Image Paths As per Requirements).
Just select main Pivot>Goto>Properties>Events Handler(Top Right Corner Flah Symbol) >Look for SelectionChanged Event and Double-Click it.Paste the Code Below There
- private void Pivot_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
- {
- switch (((Pivot)sender).SelectedIndex)
- {
- case 0:
- ApplicationBar = this.Resources["AppBar1"] as ApplicationBar;
- break;
-
- case 1:
- ApplicationBar = this.Resources["AppBar2"] as ApplicationBar;
- break;
-
- case 2:
- ApplicationBar = this.Resources["AppBar3"] as ApplicationBar;
- break;
- }
- }
- <phone:PhoneApplicationPage.Resources>
- shell:ApplicationBar x:Key="AppBar1" IsVisible="True" IsMenuEnabled="True" BackgroundColor="#FF4DC12B" ForegroundColor="White">
- <shell:ApplicationBarIconButton IconUri="/Assets/send.png" Text="Post" Click="Post_Click" />
- <shell:ApplicationBarIconButton IconUri="/Assets/appbar.refresh.png" Text="Clear" Click="Clear_Click" />
- <shell:ApplicationBar.MenuItems>
- <shell:ApplicationBarMenuItem Text="Give Feeback" Click="FeedBack_Click_1" />
- <shell:ApplicationBarMenuItem Text="About us" Click="AboustUs_Click" />
- </shell:ApplicationBar.MenuItems>
- </shell:ApplicationBar>
- <shell:ApplicationBar x:Key="AppBar2" IsVisible="True" IsMenuEnabled="True" BackgroundColor="#FF4DC12B" ForegroundColor="White">
- <shell:ApplicationBarIconButton IconUri="/Assets/feature.search.png" Text="Search" Click="Search_Click" />
- <shell:ApplicationBar.MenuItems>
- <shell:ApplicationBarMenuItem Text="Give Feeback" Click="FeedBack_Click_1" />
- <shell:ApplicationBarMenuItem Text="About us" Click="AboustUs_Click" />
- </shell:ApplicationBar.MenuItems>
- </shell:ApplicationBar>
- <shell:ApplicationBar x:Key="AppBar3" IsVisible="True" IsMenuEnabled="True" BackgroundColor="#FF4DC12B" ForegroundColor="White" Mode="Minimized">
- <shell:ApplicationBar.MenuItems>
- <shell:ApplicationBarMenuItem Text="Give Feeback" Click="FeedBack_Click_1" />
- <shell:ApplicationBarMenuItem Text="About us" Click="AboustUs_Click" />
- </shell:ApplicationBar.MenuItems>
- </shell:ApplicationBar>undefined</phone:PhoneApplicationPage.Resources>
It's Done Comment Below For Any Doubts.
This Code Works for Only Windows 8/8.1(Silverlight App's Only).