Possible to send ActionMessage from code behind?

Topics: Actions & Coroutines
Jan 30, 2012 at 4:46 PM

I want to attach an ActionMessage to an event of an attached behavior of a Telerik RadGridView:

   <utils:RowReorderBehavior Reordered="RowReorderBehaviorReordered">
         <i:EventTrigger EventName="Reordered">
            <cal:ActionMessage MethodName="RowReordered" />

This does not work because "Instances of type \"ActionMessage\" can only be attached to objects of type \"FrameworkElement\"

One solution would be to handle the Behavior's Reordered event in code behind, and generate an ActionMessage to the ViewModel from there. I can't find how to do this in code behind, could anyone point me in the right direction?

Jan 30, 2012 at 5:38 PM

I've gotten so far:

 private void RowReorderBehaviorReordered(object sender, ReorderedEventArgs e)
            var m = new ActionMessage()
                            MethodName = "RowReordered",

            var c = new ActionExecutionContext
                            Target = DataContext, 
                            Message = m, 
                            Source = radGridView, 
                            View = this,


But when after ActionMessage.InvokeAction(c) I get a NullReferenceException in ActionMessage.cs because context.Method is null. Can someone tell me what I'm doing wrong?

Jan 30, 2012 at 11:43 PM

There is a helper method called Action.Invoke. See if this will meet your needs.

Jan 31, 2012 at 3:27 PM

Thanks that does the trick :)