New to Telerik UI for WPFStart a free 30-day trial

Defines the basic methods of a generic DragDropBehavior.

Definition

Namespace:Telerik.Windows.DragDrop.Behaviors

Assembly:Telerik.Windows.Controls.dll

Type Parameters:

TState

The state type.

Syntax:

C#
public abstract class DragDropBehavior<TState> : DependencyObject, IDragDropBehavior<TState> where TState : DragDropState

Inheritance: objectDragDropBehavior<TState>

Derived Classes: TaskBoardColumnDragDropBehaviorGridViewDragDropBehaviorListBoxDragDropBehavior

Implements: IDragDropBehavior<TState>

Constructors

Initializes a new instance of the DragDropBehavior<TState> class.

C#
protected DragDropBehavior()

Fields

ItemTypeProperty

DependencyProperty

Identifies the ItemType dependency property.

C#
public static readonly DependencyProperty ItemTypeProperty

Properties

Gets or sets the value specifying whether the ListBoxDragDropBehavior can reorder items or not.

C#
public bool AllowReorder { get; set; }

Gets or sets the Type of the items that can be accepted by the host control. This is a dependency property.

C#
public Type ItemType { get; set; }

Methods

Returns a value specifying whether the current drag operation can be completed.

C#
public virtual bool CanDrop(TState state)
Parameters:stateTState

DragDropState that provides context for the current operation.

Returns:

bool

True if the drag operation can be completed, otherwise false.

Implements: IDragDropBehavior<TState>.CanDrop(TState)

Remarks:

This method is called only in the context of the drop target control.

Returns a value specifying whether the drag operation can be started.

C#
public virtual bool CanStartDrag(TState state)
Parameters:stateTState

DragDropState that provides context for the current operation.

Returns:

bool

True if the drag operation can be completed, otherwise false.

Implements: IDragDropBehavior<TState>.CanStartDrag(TState)

Remarks:

This method is called only in the context of the drag source control.

When overridden in a derived class, filters the dragged items collection if necessary.

C#
public virtual IEnumerable CoerceDraggedItems(TState state)
Parameters:stateTState

DragDropState that provides context for the current operation.

Returns:

IEnumerable

The filtered dragged items.

Implements: IDragDropBehavior<TState>.CoerceDraggedItems(TState)

Remarks:

This method is called immediately before the drag operation starts. Only the Items property of the DragDropState is valid.

Copies the items that are dragged in the operation specified by the provided ListBoxDragDropState.

C#
protected virtual IEnumerable<object> CopyDraggedItems(TState state)
Parameters:stateTStateReturns:

IEnumerable<object>

When overridden in a derived class cleans up a cancelled drag operation. This method is called only in the context of the drag source control.

C#
public virtual void DragDropCanceled(TState state)
Parameters:stateTState

DragDropState that provides context for the current operation.

Implements: IDragDropBehavior<TState>.DragDropCanceled(TState)

Remarks:

This method is called only when the drag operation is cancelled by the user. If this method is called, the source's DragDropCompleted and target's Drop methods are not called.

When overridden in a derived class completes the drag operation. This method is called only in the context of the drag source control.

C#
public virtual void DragDropCompleted(TState state)
Parameters:stateTState

DragDropState that provides context for the current operation.

Implements: IDragDropBehavior<TState>.DragDropCompleted(TState)

Remarks:

When the drag source and the drop target are the same control, this method is called after Drop. This method is called only when the drag operation completed successfully. If this method is called, DragDropCanceled is not called.

Completes the drop operation. This method is called only in the context of the drop target control.

C#
public virtual void Drop(TState state)
Parameters:stateTState

DragDropState that provides context for the current operation.

Implements: IDragDropBehavior<TState>.Drop(TState)

Remarks:

When the drag source and the drop target are the same control, this method is called before DragCompleted.

Returns the DragDropEffects for the current drag drop operation. The return value affects the mouse cursor.

C#
public virtual DragDropEffects GetDragDropEffects(TState state)
Parameters:stateTState

DragDropState that provides context for the current operation.

Returns:

DragDropEffects

Remarks:

This method is called only in the context of the drop target control.

Helper method that inserts the specified items in the source list, at the specified index. If index==-1, adds the items at the end of the list.

C#
protected static void InsertItems(IList source, int index, IEnumerable items)
Parameters:sourceIListindexintitemsIEnumerable

Returns true if the dragged items should be removed from the source list, otherwise false.

C#
protected virtual bool IsMovingItems(TState state)
Parameters:stateTState

DragDropState that provides context for the current operation.

Returns:

bool

Helper method that removes the specified items from the source list.

C#
protected static void RemoveItems(IList source, IEnumerable items)
Parameters:sourceIListitemsIEnumerable