Before reading this article, please go through the following articles-
- Developing Windows Store Apps: Introduction And Requirement Specification
- Plans For Designing Metro Style Apps (Windows Store Apps)
- Windows Store Application Life-Cycle
- Guidelines to Pass Windows Store App Certification
- Navigation Patterns to Develop Windows Store Application
- Templates to Develop Windows Store Apps
- Develop Your First Windows Store App (Hello World)
- Controls to Design Windows Store Apps
- Layout Design Guidelines For Windows Store Apps
- Guidelines to Create Splash Screen For Windows Store Application
- Configure Your Windows Store Application Using Manifest Designer
- Working With Progress Controls in Windows Store Application
Introduction
In my last article, we saw the use of progress bar control in a Windows Store app. In this article, we will see how to use a global AppBar for Windows Store applications. As all of you know, in a Windows Store application we have a new control, called AppBar. In a Windows Store app, for each page we can have two app bars, one is the TopAppBar and the second is the BottomAppBar.
If you are planning to provide navigation using app bars then we need to add app bars on each page or provide a common command for all pages using an app bar but in this case, you need to repeat the same code for all pages. In this article, we will see how to create a global app bar. We can share the app bar content across pages in the Windows Store application. Let's start by using the following procedure.
Step 1
First, you need one root page that holds our global application bar, so first, decide which single page you want as your root page. Next, add sub-pages i.e. Page1.xaml and Page2.xaml respectively.
Step 2
On the root, the page adds the app bar as in the following.
- <Page.TopAppBar>
- <AppBar x:Name="globalAppBar" Padding="10,0,10,0">
- <Grid>
- <StackPanel x:Name="leftCommandPanel
- Orientation="Horizontal" HorizontalAlignment="Left">
- <Button x:Name="Back" Style="{StaticResource BackAppBarButtonStyle}"
- AutomationProperties.Name="Back"
- Click="Back_Click"/>
- </StackPanel>
- <StackPanel x:Name="rightCommandPanel"
- Orientation="Horizontal" HorizontalAlignment="Right">
- <Button x:Name="page1Button" Content="1"
- Style="{StaticResource AppBarButtonStyle}"
- AutomationProperties.Name="Page 1"
- Click="Page1Button_Click"/>
- <Button x:Name="page2Button" Content="2"
- Style="{StaticResource AppBarButtonStyle}"
- AutomationProperties.Name="Page 2"
- Click="Page2Button_Click"/>
- </StackPanel>
- </Grid>
- </AppBar>
- </Page.TopAppBar>

Comments
Join the conversation! Your thoughts help the community grow.