Action.Target to nested VM instance?

Topics: Actions & Coroutines, Conventions
May 18, 2012 at 6:54 AM

My ShellViewModel has an instance of ApplicationViewModel. I'm trying to do this, but apparently it "could not locate any instances of contract.":

    <i:Interaction.Triggers>
        <i:EventTrigger EventName="DragEnter" cal:Action.Target="Application">
            <cal:ActionMessage MethodName="ExternalDrag">
                <cal:Parameter Value="$eventArgs" />
            </cal:ActionMessage>
        </i:EventTrigger>
    </i:Interaction.Triggers>

May 20, 2012 at 2:06 PM
Edited May 20, 2012 at 2:15 PM

In case your ShellViewModel is something like:

 

public class ShellViewModel: SomeBaseClass
{

    public object ApplicationViewModel { get; set; }
    ....
}

 

Then you can use cal:Action.TargetWithoutContext="{Binding YourPathToThePropertyOfViewModel}".

<i:Interaction.Triggers>
	<i:EventTrigger EventName="DragEnter" cal:Action.Target="Application">
		<cal:ActionMessage MethodName="ExternalDrag" cal:Action.TargetWithoutContext="{Binding ApplicationViewModel}">
                	<cal:Parameter Value="$eventArgs" />
            	</cal:ActionMessage>
        </i:EventTrigger>
</i:Interaction.Triggers