ContextMenu on tap instead of tap and hold

前端 未结 2 2008
星月不相逢
星月不相逢 2020-12-16 00:43

I need to open up a menu and since WP7 is not designed to perform such actions, I am taking help of Toolkit. Following is the sample code:



        
2条回答
  •  庸人自扰
    2020-12-16 01:16

    You could add GestureListener to the Border and subscribe to the Tap event. In the event handler, you get the ContextMenu for the Border and set IsOpen to true if it doesn't have a logical parent.

    
        
            
        
        
            
                
                
                
            
        
        
    
    
    private void GestureListener_Tap(object sender, GestureEventArgs e)
    {
        Border border = sender as Border;
        ContextMenu contextMenu = ContextMenuService.GetContextMenu(border);
        if (contextMenu.Parent == null)
        {
            contextMenu.IsOpen = true;
        }
    }
    

提交回复
热议问题