Saturday, April 6, 2013

How to use Application Bar in windows 8

How to use Application Bar in windows 8

Application bar is one of the interesting feature for any Metro style applications. Application bar allows you to define standard set of options that your application needs to use at certain context. Metro style applications are generally very clean and does not have any visual portion sharing between toolbars or application options. The app bar is the options that appear dynamically to the user when the user swipe up in the device or use Windows +Z from the keyboard.


Generally we create one application bar for the whole application, but you can also make more than one while developing an application. If you are developing an application with one bar, it is recommended to align it at bottom.
How to add an appbar on your own application
Lets take a look how you can add an appbar into your application. ApplicationBar is inherited from ContentControl, which supports swipe behaviour, also it adds up one control in its child as content. You are allowed to add more than one element as Content using StackPanel or any other panel you want to use.
<ApplicationBar VerticalAlignment="Bottom" DismissMode="LightDismiss">
             <StackPanel Orientation="Horizontal">
              <Button Click="btnStartTracking_Click" />
              <Button Click="btnEndTracking_Click" />
          </StackPanel>
         </ApplicationBar>
Here the applictionbar is added at the bottom of the application which will have two buttons. You need to create a style for these buttons if you wish this to look better. Among many other properties of applicationbar, one of the most important on is DismissMode. DismissMode determines when the application bar is going to dismiss. You can use TimeDelay, to automatically dismiss the appbar after certain amount of time, you can use EdgeSwipe which will dismiss when the application edge is swiped, but the preferred one is LightDismiss. This option will dismiss the applicationbar as soon as the user taps anywhere outside of the application.
I hope the tips comes handy. Stay tune for more.

No comments:

Post a Comment