3
votes

I've added another view named LogicView inside my MainView. I made a contextmenu for LogicView that will publish a message of "ConvertToCode()" when the menu item is clicked, but I'd like to send the message named ConvertToCode to my MainViewModel, not LogicViewModel. Otherwise, I have to use EventAggregator and publish the message from my LogicViewModel back to my MainViewModel, and this seems very redundant.

MainViewl.Xaml:

<my:LogicView x:Name="logicView" AllowDrop="True">
      <my:LogicView.ContextMenu>
          <ContextMenu StaysOpen="True">
                <MenuItem Header="Convert To Code"
                 cal:Message.Attach="ConvertToCode()"/> //I'd like to send this to mainviewmodel
          </ContextMenu>
      </my:LogicView.ContextMenu>
 </my:LogicView>

Is this possible to do in Caliburn Micro?

1

1 Answers

1
votes

This is how the problem is solved for WP7. It should apply in your case.

From the docs:

Action.TargetWithoutContext – Sets only the Action.Target property to the specified instance. String values are used to resolve an instance from the IoC container.