Dynamic ContextMenu In CodeBehind

后端 未结 3 1807
情深已故
情深已故 2021-02-13 14:28

I just want to add ContextMenu for several objects that I create dynamically, but The only way I found is to create ContextMenu in runtime like this:

ContextMen         


        
3条回答
  •  梦毁少年i
    2021-02-13 14:58

    Additionaly you can put commands on the menuItem...

    Like this:

    
    

    CommandTarget can be very important, if you use your contextMenu on different controls. I often use the FindAncestor here, to identify the caller.

提交回复
热议问题