Freitag, 2. Juli 2010

Silverlight Toolkit: Disable Drag for DragDropTarget

Each of the new DragDropTarget-Controls in the Silverlight Toolkit have a property AllowDrop which you can use to disable or enable the drop behaviour. But if you want to disable the underlaying controls to be draggable you have to cancel the drag start event at the ItemDragStarting Event:

1. Add Event handler
   1: <toolkit:TreeViewDragDropTarget ExpandNodeDelay="500"
   2:     AllowDrop="True" Drop="OnItemDropped" ItemDragStarting="TreeViewDragDropTarget_ItemDragStarting"
   3:     HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Top" >
2. Define the event handler
   1: private void TreeViewDragDropTarget_ItemDragStarting(object sender, ItemDragEventArgs e)
   2:         {
   3:             e.Cancel = true;
   4:             e.Handled = true;
   5:         }

Keine Kommentare:

Kommentar veröffentlichen