Click here to Skip to main content
13,046,499 members (72,627 online)
Click here to Skip to main content
Add your own
alternative version


2 bookmarked
Posted 26 Aug 2014

PopupMenu and Message DailogBox in Windows 8

, 26 Aug 2014
Rate this:
Please Sign up or sign in to vote.
PopupMenu and Message DailogBox in Windows 8


I am going to explain how to create a popup menu and message dailogbox in Windows Store apps. When we open any application, there is a menu bar. When we click on any menu item, the popup menu will be shown from which we can select any popup menu item. In this tip, I explain how to create a Popup menu. The message box here is fully user-defined, we can add the commands to the message box and also add an action with it.

  1. Create a new blank app name Popupmenu_N_Msgdialogbox:

  2. Add Button and Popup control in MainPage.xaml:
            <Button Content="Show Popup" 
        Click="ShowPopup" Margin="120,69,0,0" VerticalAlignment="Top"/>
            <Popup  VerticalOffset="10" 
            HorizontalOffset="300" x:Name="StandardPopup" 
                <Border BorderBrush="{StaticResource ApplicationForegroundThemeBrush}" 
                            Background="{StaticResource ApplicationPageBackgroundThemeBrush}" 
                            Width="212" Height="200">
                    <StackPanel HorizontalAlignment="Center" 
                        <TextBlock Text="Simple Popup" 
                        FontSize="24.667" HorizontalAlignment="Center"/>
                        <Button Content="Close" Click="ShowPopupClose" 
  3. And in MainPage.Xaml.cs file, add this code:
           private void ShowPopup(object sender, RoutedEventArgs e)
               if (!StandardPopup.IsOpen) { StandardPopup.IsOpen = true; }
           private void ShowPopupClose(object sender, RoutedEventArgs e)
               if (StandardPopup.IsOpen) { StandardPopup.IsOpen = false; }
  4. The output of this code is as follows:

  5. Add new Button for message dailogbox:
    <Button Content="MessageDialog Box" Click="MessageDialogBox" HorizontalAlignment="Left" Margin="120,176,0,0" 
                    VerticalAlignment="Top" Width="238"/>
  6. Add namespace in mainpage.xaml.cs file:

  7. And add this code in Mainpage.xaml.cs file:
    private async void MessageDialogBox(object sender, RoutedEventArgs e)
                var messagedialog = new MessageDialog("No internet connection has been found.");
                messagedialog.Commands.Add(new UICommand("Try again"));
                messagedialog.Commands.Add(new UICommand("Close"));
                await messagedialog.ShowAsync();
  8. The output of this code is as follows:


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Shah Ankita
Software Developer
India India
No Biography provided

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 26 Aug 2014
Article Copyright 2014 by Shah Ankita
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid