WPF Context menu doesn't bind to right databound item

前端 未结 7 1335
青春惊慌失措
青春惊慌失措 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:59

    The key thing to remember here is context menus are not part of the visual tree.

    Therefore they don't inherit the same source as the control they belong to for binding. The way to deal with this is to bind to the placement target of the ContextMenu itself.

    
    

提交回复
热议问题