WPF Context menu doesn't bind to right databound item

前端 未结 7 1333
青春惊慌失措
青春惊慌失措 2020-12-08 11:03

I have a problem when binding a command in a context menu on a usercontrol that is on a tab page. The first time I use the menu (right-click on the tab) it works great, but

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-08 11:45

    I know this is already an old post, but I would like to add another solution for those one who are looking for different ways to do it.

    I could not make the same solution to work in my case, since I was trying to do something else: open the context menu with a mouse click (just like a toolbar with a submenu attached to it) and also bind commands to my model. Since I was using an Event Trigger, the PlacementTarget object was null.

    This is the solution I found to make it work only using XAML:

    
    
    

提交回复
热议问题