I have a usercontrol with a command, what I would like to do is execute this command from the containing view's ViewModel.
This would be easy to accomplish in the code behind, as I could just go "UserControl.MyCommand.Execute", but of course I want to be able to do this in the ViewModel.
In theory, what I would like to do is bind the UserControl's Command to a Command on the ViewModel which I can execute and will then be handled by the UserControl. Something like this:
...
<local:MyControl
MyCommand="{Binding ViewModelsCommand}" />
...
Of course this will have the opposite affect to what I want to do, as now the ViewModelsCommand is bound to MyCommand. So how to invert this?
Basically I want to be able to bind something like this:
ViewModelsCommand="{Binding MyControl.MyCommand}"
Any ideas or inspiration would be welcomed, I can't see a binding Mode that would let me do this. And I'm not sure how to access the DataContext's properties for binding (usually you would do just bind and have twoway handle this, but of course that doesn't work in this scenario).
Thanks in advance.