I would like to preserve the MVVM pattern using the D&D framework on WPF 14.1. I am trying the InvokeCommandAction from System.Windows.Interactivity as seen:
<DataTemplate x:Key="ListBoxItemTemplate" DataType="{x:Type infragisticsDragDrop:Person}"> <StackPanel Background="DarkGray"> <ig:DragDropManager.DragSource> <ig:DragSource IsDraggable="True"> <i:Interaction.Triggers> <i:EventTrigger EventName="DragStart"> <i:InvokeCommandAction Command="{Binding DragStartedCommand}" /> </i:EventTrigger> </i:Interaction.Triggers> </ig:DragSource> </ig:DragDropManager.DragSource> <TextBlock Margin="2" Foreground="Red" Text="{Binding Name}" /> <TextBlock Margin="2" Foreground="Violet" Text="{Binding Age}" /> </StackPanel> </DataTemplate>
then using the template as:
<ListBox Name="Lb1" Grid.Column="0" ItemTemplate="{StaticResource ListBoxItemTemplate}" ItemsSource="{Binding People}" />
The command is never fired. I saw a similar post http://es.infragistics.com/community/forums/t/58203.aspx but could not get that to work either.
Any thoughts on what I am missing to get this to work as I intended?
Additionally, is there a way to pass the EventArgs of the Drag/Drop as part of the command parameter
Hello,
Thank you for your post. I have been looking into it and the sample you have attached and I can suggest you see this forum thread from Stackoverflow:
http://stackoverflow.com/questions/6205472/mvvm-passing-eventargs-as-command-parameter
where it is discussed how to pass the EventArgs to a command when using Interactions. I modified the sample you have attached so now both DragStart and Drop commands are bound correctly. Basically I moved the Drop command to the DragSource since this event belongs to it. If you have further questions about passing the EventArgs, I can suggest you ask them in the MSDN forum, because they are not related to Infragistics controls and there you can get an answer from an Microsoft expert.
Hope this helps you.