views:

354

answers:

1

Hi,

on my silverlight 4 app I am trying to link up the drop event on a list box to my viewmodel. I am using expression blend 4's event trigger and invokecommandaction to hook up the drop event. Setting break points on my viewmodel, I can see the relevant function is fired when I drag a file onto the list box, however I cant seem to get access to the drageventArgs. I tried sending the entire listbox as a command parameter, and that doesn't work.

Any ideas?

Thanks

A: 

I’m looking at exactly this issue at the moment. After a little research I found this http://www.silverlightshow.net/news/Silverlight-Commands-Hacks-Passing-EventArgs-as-CommandParameter-to-DelegateCommand-triggered-by-EventTrigger-.aspx

So in the meantime I’ve decided to use MVVM Light’s EventToCommand class which is similar to InvokeCommandAction but allows you to pass in the event args as the command parameter. (http://www.galasoft.ch/mvvm/getstarted/)

-- seems to work fine

<i:Interaction.Triggers>
        <i:EventTrigger EventName="Drop">
            <infra:EventToCommand  PassEventArgsToCommand="True"
                                           Command="{Binding Path=LinkOrderCommand}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
Chooksii
Thanks Chooksii.Just tried it and I get the following error:A value of type 'EventToCommand' cannot be added to a collection or dictionary of type 'TriggerActionCollection'.I have updated my galasoft dlls and am also using the latest windows.Interactivity dll.Has anyone else seen this problem?thanks
Shaggy
ok I updated galasoft references in my other viewmodels etc and it now build fine.Problem now is the updated MVVMlight dlls have broken my app :( It builds, but doesn't run :(
Shaggy