0

I'm not so great with WPF, so I am looking at a WPF control that someone else has created which has a datacontext set to another class, but also has tons of code in the code-behind on the actual control.

I need to create a context menu command that binds to a method inside of the code behind, not the actual datacontext of the control. I know how to create the context menu, just looking for how to bind to code behind when using another datacontext on the control.

Thanks!

DonnieDarko
  • 93
  • 1
  • 14
  • You can set the DataContext at the instance like – Chris W. Jul 19 '16 at 18:27
  • Thanks! I know this, I am trying to find out what "blah" should equal lol. I did try this on my command: Binding="{Binding ElementName=UserControl, Path=DeletePageCommand}"> where UserControl is the actual name of the user control. That got me intellisense and it picked up the method and everything, but it never actually fired. – DonnieDarko Jul 19 '16 at 20:24
  • Ah ok I'm not paying attention I'm sorry. ContextMenu doesn't live in the DOM the way you would expect. Try [this](http://stackoverflow.com/questions/662164/wpf-context-menu-doesnt-bind-to-right-databound-item) in which case if it's correct you might mark this as duplicate. :) – Chris W. Jul 19 '16 at 20:35
  • This does not work: – DonnieDarko Jul 19 '16 at 20:53
  • And this does not work: – DonnieDarko Jul 19 '16 at 20:58
  • This actually works in that the getter on the property is being hit whenever I expect it to however it is not actually disabling the menu item. Argggggghhhh! – DonnieDarko Jul 19 '16 at 21:02

0 Answers0