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

Load an Addin into DraftSight

These days i am developing two plugins for Autocad 2012 &  DraftSight 2013.so when i was developing the plugin i got in to big trouble.Normally in the Autocad , we can load the .dll file simply typing the command "NETLOAD" but in the Draftsight i could not able to do that. It said  " D:\c \projects\c projects\DSAddinCSharp1\ DSAddinCSharp1\bin\Debug\ DSAddinCSharp1.dll is not a valid add-in "

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.

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.