Hello i want to dynamicly add placeholder controls for drag and and drop
in xaml it would be like this:
<StackPanel Background="Transparent" Grid.Row="0" Grid.Column="0">
<ig:DragDropManager.DropTarget> <ig:DropTarget IsDropTarget="True" DropChannels="C,D" /> </ig:DragDropManager.DropTarget>
<ig:DragDropManager.DragSource> <ig:DragSource IsDraggable="True" DragChannels="D" DataObject="{Binding}"> <i:Interaction.Triggers> <i:EventTrigger EventName="DragEnd"> <my:InvokeDelegateCommandAction Command="{Binding CommandSwopField}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" /> </i:EventTrigger>
</ig:DragSource> </ig:DragDropManager.DragSource>
</StackPanel>
i have managed to write the following:
var sp = new StackPanel(); ObservableCollection<string> channels = new ObservableCollection<string>(); channels.Add("C"); channels.Add("D"); DropTarget dropTarget = new DropTarget(); dropTarget.IsDropTarget = true; dropTarget.DropChannels = channels; dropTarget.IsDropTarget = true; DragDropManager.SetDropTarget(sp, dropTarget);
channels.Clear(); channels.Add("D"); DragSource dragSource = new DragSource(); dragSource.IsDraggable = true;
dragSource.DropChannels = channels;
DragDropManager.SetDragSource(sp, dragSource);
but how to i add the even triggers with binding to command and commandparameters?
Hello Fredrik,
Thank you for your post. I have been looking into it and I created a sample project for with the functionality you want. Basically I used InvokeCommandAction as EventTrigger instead of InvokeDelegateCommandAction. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Hello i dont think you understand my question.
I cant us any xaml code, I need to add a stackpanel from code, since i need it to be added at runtime.
in this stackpanel i need to have dragsource and a droptarget. this must be added from code.
my problem is adding the event trigger such as "DRAG END". I need help to understand how i should add this programmatically with a command and DragMoveEventsArgs as command parameter