Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
535
Generate control with drag and drop framework from code
posted

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?

Parents Reply Children