Context menu sample

This sample shows how to create a context menu and how to replace the default context menu for text. This sample uses Windows.UI.Popups API, including the PopupMenu and the oncontextmenu event.

 
 
 
 
 
4.4 Star
(16)
51,089 times
Add to favorites
11/26/2013
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • I get a 'A method was called at an unexpected time.' exception (error number -2147483634)
    1 Posts | Last post September 01, 2013
    • I also test with this:
      private async void linePlot_RightClicked(object sender, PointerEventArgs args)
              {
                  
                  Dispatcher.RunAsync(CoreDispatcherPriority.Normal,() =>
                  {
                      var menu = new PopupMenu();
                      menu.Commands.Add(new UICommand("Open with", (command) =>
                      {
                      }));
                      menu.Commands.Add(new UICommand("Save attachment", (command) =>
                      {
                      }));
                      var rect = GetElementRect((FrameworkElement)sender);
                      var chosenCommand = menu.ShowForSelectionAsync(GetElementRect( (FrameworkElement)sender));
                      
                  });
              }
      but i get same exception again.
      I can't find any information about this error. please help me fix this
  • I get a 'A method was called at an unexpected time.' exception (error number -2147483634)
    1 Posts | Last post September 01, 2013
    • hi
      I tried to test this sample with consecutive right clicks on the image in the first example but i get a  'A method was called at an unexpected time.' exception (error number -2147483634) on the menu.ShowForSelectionAsync(GetElementRect((FrameworkElement)sender))
      in my own app i tried to call a popup menu from a non ui thread but i get this exception more times than your sample. this is my code:
      
       private async void linePlot_RightClicked(object sender, PointerEventArgs args)
              {
                  
                  Dispatcher.RunAsync(CoreDispatcherPriority.Normal,async () =>
                  {
                      var menu = new PopupMenu();
                      menu.Commands.Add(new UICommand("Open with", (command) =>
                      {
                      }));
                      menu.Commands.Add(new UICommand("Save attachment", (command) =>
                      {
                      }));
                      var rect = GetElementRect((FrameworkElement)sender);
                      var chosenCommand = await             menu.ShowForSelectionAsync(GetElementRect((FrameworkElement)sender));
                      
                  });
              }