Menu Dialog

As demonstrated in the mobile application, menu dialog displays a list of options with a background form that is unavailable. This creates a dialog that mimics the context menu user experience as in the win32 platform. A simple use case would be showing the user a list of ILocations you get from GeoRSS feed, and when tapped, displaying a menu dialog box with actions the user can choose from, such as View On Map, Navigate to, and so on.

The MenuDialog takes full advantage of the screen real estate on a mobile device to maximize the display area, while optionally showing the previous Page in the background to give you the context.

The following code demonstrates how to construct a simple MenuDialog with the WorkkListTask.WorkListPage unavailable in the background.

      MenuDialog<string> menuDialog = null;
      try
      {
        // create list of strings
        List<string> menuItems = new List<string>();
        menuItems.Add("Option1");
        menuItems.Add("Option2"); 

        // instantiate the form
        // param 1: list of items
        // param 2: want to show cancel item?
        // param 3: background form
        menuDialog = new MenuDialog<string>("Options", menuItems, true, MobileApplication.Current.Project.WorkListTask.WorkListPage);
        if (MobileApplication.Current.ShowDialog(menuDialog) == System.Windows.Forms.DialogResult.OK)
        {
          // user chose an option
          if (menuDialog.SelectedItem == "Option1")
          {
            // do something
          }
          else if (menuDialog.SelectedItem == "Option2")
          {
            // do something else
          }
        }
        else
        {
          // user cancelled
          return;
        }
      }
      finally
      {
        // make sure to dispose the menu dialog, it holds onto a bitmap
        if (menuDialog != null)
          menuDialog.Dispose();
      }

This is required


9/20/2011