Reputation: 1477
I have a ListView that I need to function as a drop target. I have added the following trigger
<i:Interaction.Triggers>
<i:EventTrigger EventName="Drop">
<i:InvokeCommandAction Command="{Binding ItemsDroppedCommand}"
CommandParameter="{Binding ???}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
The problem is though I dont know how to get the dropped items. What should go in the CommandParameter binding?
If I do a drop handler in code behind I get a DragEventArgs parameter that enables me to get the files dropped. Is there a way to get this?
If this is the wrong approach please feel free to suggest alternatives
Upvotes: 3
Views: 2996
Reputation: 59983
Passing an event's arguments to a Command through binding isn't supported out of the box but can be achieved through a workaround.
However, I would recommend you to use the EventToCommand behavior available in MVVM Light, which enables exactly this scenario:
<i:Interaction.Triggers>
<i:EventTrigger EventName="Drop">
<cmd:EventToCommand Command="{Binding ItemsDroppedCommand}"
PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
Upvotes: 3
Reputation: 1435
please take a look on this thread MVVM Passing EventArgs As Command Parameter
In this thread will help you solve the problem. I hope this help.
Upvotes: 2