MVVM Drag and Drop

Nov 17, 2010 at 2:43 PM

Hi

I am trying to implement drag and drop functionality using Telerik controls using the MVVM pattern.

I have an example of it working with the MVVM Light Toolkit as follows:

<i:Interaction.Triggers>
        <local:DragDropQueryRoutedEventTrigger EventName="DragQuery" EventOwnerType="{x:Type telerik:RadDragAndDropManager}">
        	<GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding Command}" PassEventArgsToCommand="true"/>
        </local:DragDropQueryRoutedEventTrigger>
</i:Interaction.Triggers>

I would like to do something similar using CM as follows

<i:EventTrigger EventName="DragQuery">
    <cal:ActionMessage MethodName="DragQuery" >
        <cal:Parameter Value="$eventArgs" />
    </cal:ActionMessage>
</i:EventTrigger>

The problem with the above code is that CM is looking for the DragQuery event on my RadGridView control, but the event is actually being raised on the RadDragAndDropManager as specified in the EventOwnerType property from the first code block.

Is there some way of telling the ActionMessage to go look for the event on a specific Type or am I missing something obvious?

Regards

Dirk

Coordinator
Nov 17, 2010 at 3:24 PM

You can use any TriggerBase with ActionMessage. Have you tried something like this?

<i:Interaction.Triggers>
   <local:DragDropQueryRoutedEventTrigger EventName="DragQuery" EventOwnerType="{x:Type telerik:RadDragAndDropManager}">       	
    <cal:ActionMessage MethodName="DragQuery" >
        <cal:Parameter Value="$eventArgs" />
    </cal:ActionMessage>
</local:DragDropQueryRoutedEventTrigger> </i:Interaction.Triggers>

 

Nov 17, 2010 at 3:57 PM

Thanks!

That did the trick, I WAS missing something obvious. Didn't realise the DragDropQueryRoutedEventTrigger was a custom class, thought it was part of the MVVM Light Toolkit.