Skip to main content

How to create app bar with menu windows 8 (Windows Store apps using C# and XAML)

Hi Guys..
These days i am interesting in windows 8 app developing because i have to create 20 windows 8 apps for Microsoft student champs .So i decided to create series of post "How to Create windows 8 app".
Actually i am not going to start this in beginner level but if you requested then i can consider about it.  Lets go to the my fist post in "How to Create windows 8 app"


When you add commands to an app bar, consider whether your command sets would work better in a command menu. Menus let you present more options in less space and include interactive controls. In this example, the Sort menu pops up a simple list that makes choosing options easy.


Step 1: Add an app bar to the app

  • Add an app bar to your app.Here, we add a bottom app bar with a button to show the sort menu.
 <Page.BottomAppBar>  
   <AppBar x:Name="bottomAppBar" IsSticky="True">  
     <Grid>  
       <StackPanel x:Name="rightPanel"   
             Orientation="Horizontal" HorizontalAlignment="Right">  
         <Button Style="{StaticResource AppBarButtonStyle}"   
             Content="&#xE174;"   
             AutomationProperties.Name="Sort"  
             AutomationProperties.AutomationId="SortButton"  
             Click="SortMenuButton_Click" />  
       </StackPanel>  
     </Grid>  
   </AppBar>  
 </Page.BottomAppBar>  


Step 2: Show the menu pop up

When a user clicks the Sort command button on the AppBar, you show a Popup menu. The user picks a sort option from the menu.

  1. Create a Popup to host the sort menu.
  2.  Popup popUp = new Popup();  


  3. Set the Popup.IsLightDismissEnabled property to true.
    With light dismiss enabled, the Popup hides automatically when the user interacts with another part of the app.
  4.  popUp.IsLightDismissEnabled = true;  
    


  5. Create a panel as the root of the menu UI.
  6.  StackPanel panel = new StackPanel();  
     panel.Background = bottomAppBar.Background;  
     panel.Height = 140;  
     panel.Width = 180;  
    


  7. Add command buttons to the menu UI.
  8.  Button byRatingButton = new Button();  
     byRatingButton.Content = "By rating";  
     byRatingButton.Style = (Style)App.Current.Resources["TextButtonStyle"];  
     byRatingButton.Margin = new Thickness(20, 5, 20, 5);  
     byRatingButton.Click += SortButton_Click;  
     panel.Children.Add(byRatingButton);  
    


  9. Add the menu root panel as the Popup content.
  10.  popUp.Child = panel;  
    


  11. Calculate the placement of the Popup menu.
    Here, we place the Popup in the bottom right corner of the screen, above the AppBar, with a padding of 4.
  12.  popUp.HorizontalOffset = Window.Current.CoreWindow.Bounds.Right - panel.Width - 4;  
     popUp.VerticalOffset = Window.Current.CoreWindow.Bounds.Bottom - bottomAppBar.ActualHeight - panel.Height - 4;  
    


  13. Open the Popup.
  14.  popUp.IsOpen = true;  
    


    Thank You Guys :)

Comments

Popular posts from this blog

Imagine Cup 2014

Hi guys .. Get ready for imagine cup 2014 In NewZealand .In the next few days imagine cup 2013 finals will happen in Russia. So It is time to wear your thinking hat.You have one year to develop your marvelous ideas.  The Microsoft Imagine Cup is the world’s most prestigious student technology competition, bringing together student innovators from all over the world. If you have a great idea for a new app, bring it to life through Imagine Cup. Over the past 10 years, more than 1.65 million students from 190 countries have participated in the Imagine Cup. 

Visual Studio 2013 New Editor Features

In Visual Studio 2013, we have introduced new features that boost productivity and save time when working inside the Editor. Some of these are new features and some are the most popular extensions from  Productivity Power Tools . These features are a result of the feedback you gave us through  User Voice  requests, forum posts and Connect bugs. The MVP community also helped us pick some of these experiences. Our primary focus for the Editor in this version is to keep the developer in context as much as possible. This blog post describes capabilities that bring information to your fingertips and allow you to do as much as possible without leaving your place in code.

C# Character Escape Sequences

Character combinations consisting of a backslash ( \ ) followed by a letter or by a combination of digits are called "escape sequences." To represent a newline character, single quotation mark, or certain other characters in a character constant, you must use escape sequences. An escape sequence is regarded as a single character and is therefore valid as a character constant.