Caliburn with Async CTP

Dec 14, 2010 at 3:26 PM

I am working to include the new Async CTP in my Caliburn application. I think there is a problem because the binding of Caliburn does not call the method in my viewmodel in the new async way. 

Here is my xaml (part of an itemcontrol)

 

<i:Interaction.Triggers>
        <i:EventTrigger EventName="MouseLeftButtonDown">
      	   <Micro:ActionMessage MethodName="DoEdit" >
                <Micro:Parameter Value="$dataContext" />     
           </Micro:ActionMessage>
       </i:EventTrigger>
</i:Interaction.Triggers>

DoEdit in my viewmodel looks like this:

        public async void DoEdit(Person person)
        {
            PersonenViewModel vm = new PersonenViewModel(person);
            await vm.LoadAsync();
            vm.DisplayName = person.Titel;
            Edit(vm);
        }

As far as I understand in order for the await to wait the method has to be called by a method that also is defined as async.

Do I have to make a change to the Caliburn Framework? Where would I have to look find the place to implement this change?

 

Coordinator
Dec 14, 2010 at 3:52 PM

Caliburn.Micro will not work with async methods without some alteration. Async methods can be called via reflection, but I believe you need to handle the task that is returned manually. I haven't tried it myself yet. You can add the new code by replacing the ActionMessage.InvokeAction func with your own code.