Application Bar in Windows 8


The name Application Bar sounds similar to Taskbar. In fact, yes they are similar to some extent.
ApplicationBar is a concept of WindowsRT whereas Taskbar belongs to the conventional Windows OS.


So, our agenda for this article will be:
  • Try to get a basic idea of an Application Bar
  • Learn how to put it into a Windows Store XAML App
  • Deal with related events

Exploring Application Bars

If you are familiar with Windows 8 or the Windows RT OS then you must have tried Windows Store Apps. And there you may have seen some Horizontal Bar at the bottom of the screen.
It appears when you right-click your mouse.
It looks like.
It's just like an Application Bar in Windows Phone.
Unlike Windows Phone, here you can manipulate the styling and design yourself.
Now, Put it in XAML
Step 1
Start a Blank Windows Store project and get inside the XAML window (MainPage.xaml).
Step 2
We will now provide the XAML for the Application Bar. And ensure that your XAML is below the main Grid section (in other words below the </Grid> line).
We will first start with <Page.BottomAppBar>.
And then define the AppBar.
  1. <AppBar x:Name="myApplicationBar" Padding="10">    
Here I have named my AppBar "myApplicationBar" with internal padding of 10.
Within these tags, provide the Appbar buttons using a horizontal stack panel.
  1. <Grid>    
  2. <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">    
  3. <AppBarButton IsCompact="True" Icon="Accept"/>    
  4. <AppBarButton IsCompact="True" Icon="AddFriend"/>    
  5. <AppBarButton IsCompact="True" Icon="Admin"/>    
  6. <AppBarSeparator/>    
  7. <AppBarButton IsCompact="True" Icon="Calculator"/>    
  8. </StackPanel>    
  10. <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">    
  11. <AppBarButton IsCompact="True" Icon="Delete"/>    
  12. </StackPanel>    
  13. </Grid>   
Most of the code is obvious, except what IsCompact and AppBarSeprator do.
The IsCompact button reduces the extra space between the alernate buttons.
And AppBarSeprator adds a seprator-line like ( | ).
So the outcome will be.
We will now add a Click event.
The same as you do in any Windows Phone app or XAML oriented application, in other words, the Click property with their event handler method name.
So, add the Click properly as in the following.
  1. <AppBarButton IsCompact="True" Icon="Accept" Click="AppBarButton_Click"/>    
We now have an event handler method in the CS file.
There, we will try to provide a Message Box.
  1. private void AppBarButton_Click(object sender, RoutedEventArgs e)    
  2. {    
  3. // This is the event Handler    
  4. // Now, we will put a Message Box    
  5. var messageDialog = new MessageDialog("Hello C# Corner");    
  6. messageDialog.ShowAsync();    
  7. }    
You need to use Windows.UI.Popups for MessageDialog()


It's just a fundamental part of Windows 8 application development. Try to go figure out more from the MSDN if you need to ( ).
And, if you need a detailed view of AppBar icons then you can check them from here ( ).
Regrading this article, if you encounter any problem then go for the Solution file or PING me :)
Stay Raw, Stay Geek and Keep Coding :) 

Similar Articles