What you want to see on DotNetFunda.com ?
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 41490 |  Welcome, Guest!   Register  Login
Home > Articles > Windows 8 > Windows 8 App Features - App Bar Advanced

Windows 8 App Features - App Bar Advanced

1 vote(s)
Rating: 4 out of 5
Article posted by Ambily.Raj on 10/31/2012 | Views: 1521 | Category: Windows 8 | Level: Advance | Points: 250 red flag


Windows 8 introduced a whole new style of application development. Windows 8 Style applications display Content over Chrome. This new style of application development help the end user to develop touch enabled applications with the same style as Windows 8. Windows 8 Style applications are based on Tiles, App Bars, Contracts, etc. We will be discussing about various Windows 8 features in a series of articles. In this article we will discuss about the App Bar feature.

 
App Bar


App bars are the navigation or command bars hidden in top or bottom edges of the screen. We have already discussed about the App Bar in the article Windows 8 App Features – App Bar.


In this document we will discuss about the App Bar declaration using a custom icon and take a closer look into the Global App Bar implementation.


App Bar with Custom Icon

Windows 8 provides a list of frequently used App Bar icons; but in some cases we may need to define our icon and content for the App Bar. Following sample shows how we can use a built-in App Bar icon and how we can define a custom App Bar icon


Play App Bar icon, which is defined by the Windows 8

<Button Style="{StaticResource PlayAppBarButtonStyle}"/>


Custom image and content


        

 <Button x:Name="customer" Click="customer_Click">

                        <Button.Content>
                                <StackPanel Orientation="Vertical">
                                        <Image Source="Assets/Customer.png" Width="40"/>
                                        <TextBlock Text="Customer"/>
                            </StackPanel>
                        </Button.Content>
                </Button>


 
 
Page Specific App Bar


As specified in the previous article, we are using a global App Bar for defining the main App Bar, which will be available for all the pages. Apart from this global App Bar, some pages may have specific App Bar requirements like the Customer page may require two more actions like New Customer, Edit Customer, etc.


For defining a page specific App Bar icon along with the Global App Bar, access the global App Bar in OnNavigateTo method and add the new icons to it.


Global App Bar declaration


 

<Page.BottomAppBar>
            <AppBar >
                    <StackPanel Orientation="Horizontal" x:Name="bottomAppBar">
                            <Button x:Name="utility" Click="utility_Click">
                                    <Button.Content>
                                            <StackPanel Orientation="Vertical">
                                                   <Image Source="Assets/utility.png" Width="40"/>
                                                   <TextBlock Text="Utility"/>
                                        </StackPanel>
                                    </Button.Content>
                            </Button>
        ----------------------------------------
        </StackPanel>
            </AppBar>
   < /Page.BottomAppBar> 


 
Accessing the Global App Bar in Customer Page and adding a new icon for “New Customer” action.


 

protected async override void OnNavigatedTo(NavigationEventArgs e)

        {
            rootPage         = e.Parameter as MainPage;
                    bottomAppBarPnl = rootPage.FindName("bottomAppBar") as StackPanel;
            if(bottomAppBarPnl != null)
            {                        // Create the button to add                       newCust = new Button();
                        newCust.Content = "New Customer";
                        newCust.Click += new RoutedEventHandler(newCust_Click);
 
                        // Add the button to the AppBar
                        bottomAppBarPnl.Children.Add(newCust);
            }
        }

 
When navigating to another page, we need to remove the New Customer action icon from App Bar. Define the removal in the OnNavigateFrom method.


 

protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)

        {
                   if(bottomAppBarPnl != null)
            {
                        // Unhook the Click event handler for the button
                        newCust.Click -= new RoutedEventHandler(newCust_Click);
 
                   // Remove the button from the AppBar
                        bottomAppBarPnl.Children.Remove(newCust);
            }
}

 
Conclusion


Windows 8 introduced the new Windows 8 Style application development, which enable the user to develop quick touch enabled applications with a new style. App Bar is one of the major features in Windows 8 Application development.

 

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

About Ambily KK

Experience:9 year(s)
Home page:http://ambilykk.com/
Member since:Tuesday, May 18, 2010
Level:Silver
Status: [Member] [Microsoft_MVP] [MVP]
Biography:I have over 9 years of experience working on Microsoft Technologies. I am carrying the passion on Microsoft technologies specifically on web technologies such as ASP .Net and Ajax. My interests also include Office Open XML, Azure, Visual Studio 2010. Technology adoption and learning is my key strength and technology sharing is my passion.
>> Write Response - Respond to this post and get points
Related Posts

Windows 8 introduced a whole new style of application development. Windows 8 Style applications display Content over Chrome. This new style of application development help the end user to develop touch enabled applications with the same style as Windows 8. Windows 8 Style applications are based on Tiles, App Bars, Contracts, etc. We will be discussing about various Windows 8 features in a series of articles. In this article we will discuss about the App Bar feature.

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/21/2013 8:18:22 AM