Class DragDropTarget<TItemsControlType, TItemContainerType>
A control that enabled drag and drop operations on an ItemsControl.
Inheritance
Implements
Inherited Members
Namespace: System.Windows.Controls
Assembly: OpenSilver.Controls.Toolkit.dll
Syntax
public abstract class DragDropTarget<TItemsControlType, TItemContainerType> : ContentControl, IControl, IFrameworkElement, IUIElement, IDependencyObject, IAcceptDrop where TItemsControlType : UIElement where TItemContainerType : UIElement
Type Parameters
Name | Description |
---|---|
TItemsControlType | The type of the items control. |
TItemContainerType | The type of the item container. |
Constructors
| Improve this Doc View SourceDragDropTarget()
Initializes a new instance of the ItemsControlDragAdorner class.
Declaration
protected DragDropTarget()
Fields
| Improve this Doc View SourceAllowedSourceEffectsProperty
Identifies the AllowedSourceEffects dependency property.
Declaration
public static readonly DependencyProperty AllowedSourceEffectsProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
DragContainerName
The name of the DragContainer template part.
Declaration
protected const string DragContainerName = "DragContainer"
Field Value
Type | Description |
---|---|
System.String |
DragDecoratorName
The name of the DragDecorator template part.
Declaration
protected const string DragDecoratorName = "DragDecorator"
Field Value
Type | Description |
---|---|
System.String |
DragPopupName
The name of the DragPopup template part.
Declaration
protected const string DragPopupName = "DragPopup"
Field Value
Type | Description |
---|---|
System.String |
InsertionIndicatorContainerName
The name of the insertion indicator container.
Declaration
protected const string InsertionIndicatorContainerName = "InsertionIndicatorContainer"
Field Value
Type | Description |
---|---|
System.String |
InsertionIndicatorName
The name of the insertion indicator template part.
Declaration
protected const string InsertionIndicatorName = "InsertionIndicator"
Field Value
Type | Description |
---|---|
System.String |
Properties
| Improve this Doc View SourceAllowedSourceEffects
Gets or sets the allowed effects when this DragDropTarget is the drag source.
Declaration
public DragDropEffects AllowedSourceEffects { get; set; }
Property Value
Type | Description |
---|---|
DragDropEffects |
Methods
| Improve this Doc View SourceAddItem(TItemsControlType, Object)
Adds an item to an items control.
Declaration
protected abstract void AddItem(TItemsControlType itemsControl, object data)
Parameters
Type | Name | Description |
---|---|---|
TItemsControlType | itemsControl | The items control. |
System.Object | data | The data to be inserted. |
CanAddItem(TItemsControlType, Object)
Returns a value indicating whether an item can be added to the items control.
Declaration
protected abstract bool CanAddItem(TItemsControlType itemsControl, object data)
Parameters
Type | Name | Description |
---|---|---|
TItemsControlType | itemsControl | The items control. |
System.Object | data | The data to be added. |
Returns
Type | Description |
---|---|
System.Boolean | A value indicating whether an item can be added to the items control. |
CanRemove(TItemsControlType)
Returns a value indicating whether an item can be removed from the items control.
Declaration
protected abstract bool CanRemove(TItemsControlType itemsControl)
Parameters
Type | Name | Description |
---|---|---|
TItemsControlType | itemsControl | The items control. |
Returns
Type | Description |
---|---|
System.Boolean | A value indicating whether an item can be removed from the items control. |
CanScroll(TItemsControlType)
Returns a value indicating whether a given items control can scroll.
Declaration
protected virtual bool CanScroll(TItemsControlType itemsControl)
Parameters
Type | Name | Description |
---|---|---|
TItemsControlType | itemsControl | The items control. |
Returns
Type | Description |
---|---|
System.Boolean | The value indicating whether the given items control can scroll. |
ContainerFromIndex(TItemsControlType, Int32)
Retrieves the item container at a given index.
Declaration
protected abstract TItemContainerType ContainerFromIndex(TItemsControlType itemsControl, int index)
Parameters
Type | Name | Description |
---|---|---|
TItemsControlType | itemsControl | The items control. |
System.Int32 | index | The index at which to retrieve the container. |
Returns
Type | Description |
---|---|
TItemContainerType | The item container at a given index. |
GetDropTarget(DragEventArgs)
Retrieves the drop target of a drag event.
Declaration
protected virtual TItemsControlType GetDropTarget(DragEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DragEventArgs | args | Information about the drag event. |
Returns
Type | Description |
---|---|
TItemsControlType | The drop target of a drag event. |
GetDropTargetInsertionIndex(TItemsControlType, DragEventArgs)
Gets the adjusted insertion index within a drop target given information about a drag event.
Declaration
protected int GetDropTargetInsertionIndex(TItemsControlType dropTarget, DragEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
TItemsControlType | dropTarget | The drop target. |
DragEventArgs | args | Information about a drag event. |
Returns
Type | Description |
---|---|
System.Int32 | The insertion index within the drop target. |
GetDropTargetInsertionIndexOverride(TItemsControlType, DragEventArgs)
Gets the insertion index within a drop target given information about a drag event.
Declaration
protected virtual int GetDropTargetInsertionIndexOverride(TItemsControlType dropTarget, DragEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
TItemsControlType | dropTarget | The drop target. |
DragEventArgs | args | Information about a drag event. |
Returns
Type | Description |
---|---|
System.Int32 | The insertion index within the drop target. |
GetInsertionIndicatorGeometry(TItemsControlType, Int32, DragEventArgs)
Returns a geometry to use for the insertion indicator given an item container, the orientation of the items host panel, and a value indicating whether to insert before or after the item container.
Declaration
protected virtual Geometry GetInsertionIndicatorGeometry(TItemsControlType dropTarget, int insertionIndex, DragEventArgs dragEventArgs)
Parameters
Type | Name | Description |
---|---|---|
TItemsControlType | dropTarget | The drop target. |
System.Int32 | insertionIndex | The index at which to insert the item. |
DragEventArgs | dragEventArgs | Information about the drag event. |
Returns
Type | Description |
---|---|
Geometry | The geometry to use for the insertion indicator given information about an IndicatingInsertionLocation event. |
GetItemContainerAncestor(TItemsControlType, DependencyObject)
Returns the item container ancestor of a dependency object.
Declaration
public virtual TItemContainerType GetItemContainerAncestor(TItemsControlType itemsControl, DependencyObject dependencyObject)
Parameters
Type | Name | Description |
---|---|---|
TItemsControlType | itemsControl | The items control that contains the item container. |
DependencyObject | dependencyObject | The dependency object. |
Returns
Type | Description |
---|---|
TItemContainerType | The item container ancestor of the dependency object. |
GetItemCount(TItemsControlType)
Gets the number of items in an items control.
Declaration
protected abstract int GetItemCount(TItemsControlType itemsControl)
Parameters
Type | Name | Description |
---|---|---|
TItemsControlType | itemsControl | The items control. |
Returns
Type | Description |
---|---|
System.Int32 | The number of items in the items control. |
GetItemsControlAncestor(DependencyObject)
Returns the items control ancestor of a dependency object.
Declaration
protected virtual TItemsControlType GetItemsControlAncestor(DependencyObject dependencyObject)
Parameters
Type | Name | Description |
---|---|---|
DependencyObject | dependencyObject | The dependency object to retrieve the element for. |
Returns
Type | Description |
---|---|
TItemsControlType | The items control ancestor of the dependency object. |
GetItemsHost(TItemsControlType)
Retrieves the items host for a given items control.
Declaration
protected abstract Panel GetItemsHost(TItemsControlType itemsControl)
Parameters
Type | Name | Description |
---|---|---|
TItemsControlType | itemsControl | The items control. |
Returns
Type | Description |
---|---|
Panel | The items host for a given items control. |
IndexFromContainer(TItemsControlType, TItemContainerType)
Retrieves the index of an item container.
Declaration
protected abstract int? IndexFromContainer(TItemsControlType itemsControl, TItemContainerType itemContainer)
Parameters
Type | Name | Description |
---|---|---|
TItemsControlType | itemsControl | The items control. |
TItemContainerType | itemContainer | The item container. |
Returns
Type | Description |
---|---|
System.Nullable<System.Int32> | The index of an item container. |
InsertItem(TItemsControlType, Int32, Object)
Inserts an item into an items control.
Declaration
protected abstract void InsertItem(TItemsControlType itemsControl, int index, object data)
Parameters
Type | Name | Description |
---|---|---|
TItemsControlType | itemsControl | The items control. |
System.Int32 | index | The index at which to insert the item. |
System.Object | data | The data to be inserted. |
INTERNAL_OnAttachedToVisualTree()
Declaration
protected override void INTERNAL_OnAttachedToVisualTree()
Overrides
| Improve this Doc View SourceIsDragWithinDragSource(DragEventArgs)
Returns a value indicating whether an item is being dragged within the drag source.
Declaration
protected bool IsDragWithinDragSource(DragEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DragEventArgs | args | Information about the drag event. |
Returns
Type | Description |
---|---|
System.Boolean | A value indicating whether an item is being dragged within the drag source. |
IsItemContainerOfItemsControl(TItemsControlType, DependencyObject)
Returns a value indicating whether a container belongs to an items control.
Declaration
protected abstract bool IsItemContainerOfItemsControl(TItemsControlType itemsControl, DependencyObject itemContainer)
Parameters
Type | Name | Description |
---|---|---|
TItemsControlType | itemsControl | The items control. |
DependencyObject | itemContainer | The item container. |
Returns
Type | Description |
---|---|
System.Boolean | A value indicating whether a container belongs to an items control. |
ItemFromContainer(TItemsControlType, TItemContainerType)
Gets the item from an item container.
Declaration
protected abstract object ItemFromContainer(TItemsControlType itemsControl, TItemContainerType itemContainer)
Parameters
Type | Name | Description |
---|---|---|
TItemsControlType | itemsControl | The items control. |
TItemContainerType | itemContainer | The item container. |
Returns
Type | Description |
---|---|
System.Object | The data contained by the item container. |
OnApplyTemplate()
This method is invoked when the template is applied.
Declaration
public override void OnApplyTemplate()
Overrides
| Improve this Doc View SourceOnDragEnter(DragEventArgs)
Raises the DragEnter event.
Declaration
protected virtual void OnDragEnter(DragEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DragEventArgs | args | Information about the event. |
OnDragEvent(DragEventArgs)
Updates the drag event information whenever a drag event occurs.
Declaration
protected virtual void OnDragEvent(DragEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DragEventArgs | args | Information about the event. |
OnDragLeave(DragEventArgs)
Raises the DragLeave event.
Declaration
protected virtual void OnDragLeave(DragEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DragEventArgs | args | Information about the event. |
OnDragOver(DragEventArgs)
Raises the DragOver event.
Declaration
protected virtual void OnDragOver(DragEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DragEventArgs | args | Information about the event. |
OnDrop(DragEventArgs)
An method that invokes the Drop event.
Declaration
protected virtual void OnDrop(DragEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DragEventArgs | args | Information about the event. |
OnDropOverride(DragEventArgs)
Adds data to the drop target.
Declaration
protected virtual void OnDropOverride(DragEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DragEventArgs | args | Information about the Drop event. |
OnGiveFeedback(GiveFeedbackEventArgs)
Raises the GiveFeedback event.
Declaration
protected virtual void OnGiveFeedback(GiveFeedbackEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
GiveFeedbackEventArgs | args | Information about the event. |
OnIndicatingInsertionLocation(IndicatingInsertionLocationEventArgs<TItemsControlType>)
A method which raises the IndicatingInsertionLocation event.
Declaration
protected virtual void OnIndicatingInsertionLocation(IndicatingInsertionLocationEventArgs<TItemsControlType> args)
Parameters
Type | Name | Description |
---|---|---|
IndicatingInsertionLocationEventArgs<TItemsControlType> | args | Information about the event. |
OnItemDragCompleted(ItemDragEventArgs)
This method is invoked when an item drag is completed.
Declaration
protected virtual void OnItemDragCompleted(ItemDragEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
ItemDragEventArgs | args | Information about the event. |
OnItemDragStarting(ItemDragEventArgs)
A method that raises the item drag starting event.
Declaration
protected virtual void OnItemDragStarting(ItemDragEventArgs eventArgs)
Parameters
Type | Name | Description |
---|---|---|
ItemDragEventArgs | eventArgs | Information about the drag starting event. |
OnItemDroppedOnSource(DragEventArgs)
Raises the ItemDroppedOnSource event.
Declaration
public virtual void OnItemDroppedOnSource(DragEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DragEventArgs | args | Information about the ItemDroppedOnSource event. |
OnItemDroppedOnTarget(ItemDragEventArgs)
Raises the ItemDragCompleted event.
Declaration
protected virtual void OnItemDroppedOnTarget(ItemDragEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
ItemDragEventArgs | args | Information about the event. |
OnQueryContinueDrag(QueryContinueDragEventArgs)
Raises the QueryContinueDrag event.
Declaration
protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
QueryContinueDragEventArgs | args | Information about the event. |
RemoveItem(TItemsControlType, Object)
Removes an item from an items control.
Declaration
protected abstract void RemoveItem(TItemsControlType itemsControl, object data)
Parameters
Type | Name | Description |
---|---|---|
TItemsControlType | itemsControl | The items control. |
System.Object | data | The data to be removed. |
RemoveItemAtIndex(TItemsControlType, Int32)
Removes an item from an items control by index.
Declaration
protected virtual void RemoveItemAtIndex(TItemsControlType itemsControl, int index)
Parameters
Type | Name | Description |
---|---|---|
TItemsControlType | itemsControl | The items control. |
System.Int32 | index | The index of the item to be removed. |
ScrollIntoView(TItemsControlType, TItemContainerType)
Scrolls a given item container into the view.
Declaration
protected virtual void ScrollIntoView(TItemsControlType itemsControl, TItemContainerType itemContainer)
Parameters
Type | Name | Description |
---|---|---|
TItemsControlType | itemsControl | The items control that contains the item container. |
TItemContainerType | itemContainer | The item container to scroll into view. |
Events
| Improve this Doc View SourceDragEnter
An event raised when the an item is dragged into the adorner.
Declaration
public event DragEventHandler DragEnter
Event Type
Type | Description |
---|---|
DragEventHandler |
DragLeave
An event raised when the an item is dragged out of the adorner.
Declaration
public event DragEventHandler DragLeave
Event Type
Type | Description |
---|---|
DragEventHandler |
DragOver
An event raised when the an item is dragged over the adorner.
Declaration
public event DragEventHandler DragOver
Event Type
Type | Description |
---|---|
DragEventHandler |
Drop
An event raised when the an item is dropped onto the adorner.
Declaration
public event DragEventHandler Drop
Event Type
Type | Description |
---|---|
DragEventHandler |
GiveFeedback
An event raised when the feedback about the drag operations is requested from the adorner.
Declaration
public event GiveFeedbackEventHandler GiveFeedback
Event Type
Type | Description |
---|---|
GiveFeedbackEventHandler |
ItemDragCompleted
An event raised when the an item drag is completed.
Declaration
public event EventHandler<ItemDragEventArgs> ItemDragCompleted
Event Type
Type | Description |
---|---|
System.EventHandler<ItemDragEventArgs> |
ItemDragStarting
An event raised when a drag operation is starting on an item.
Declaration
public event EventHandler<ItemDragEventArgs> ItemDragStarting
Event Type
Type | Description |
---|---|
System.EventHandler<ItemDragEventArgs> |
ItemDroppedOnSource
An event raised when the an item is dropped onto the adorner.
Declaration
public event DragEventHandler ItemDroppedOnSource
Event Type
Type | Description |
---|---|
DragEventHandler |
ItemDroppedOnTarget
This event is raised when an item is dropped on a target.
Declaration
public event EventHandler<ItemDragEventArgs> ItemDroppedOnTarget
Event Type
Type | Description |
---|---|
System.EventHandler<ItemDragEventArgs> |
QueryContinueDrag
An event raised when the adorner is queries regarding the drag operation.
Declaration
public event QueryContinueDragEventHandler QueryContinueDrag
Event Type
Type | Description |
---|---|
QueryContinueDragEventHandler |
Explicit Interface Implementations
| Improve this Doc View SourceIAcceptDrop.OnDragEnter(DragEventArgs)
Raises the DragEnter event.
Declaration
void IAcceptDrop.OnDragEnter(DragEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DragEventArgs | args | Information about the event. |
IAcceptDrop.OnDragLeave(DragEventArgs)
Raises the DragLeave event.
Declaration
void IAcceptDrop.OnDragLeave(DragEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DragEventArgs | args | Information about the event. |
IAcceptDrop.OnDragOver(DragEventArgs)
Raises the DragOver event.
Declaration
void IAcceptDrop.OnDragOver(DragEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DragEventArgs | args | Information about the event. |
IAcceptDrop.OnDrop(DragEventArgs)
Raises the Drop event.
Declaration
void IAcceptDrop.OnDrop(DragEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
DragEventArgs | args | Information about the event. |
IAcceptDrop.OnGiveFeedback(GiveFeedbackEventArgs)
Raises the GiveFeedback event.
Declaration
void IAcceptDrop.OnGiveFeedback(GiveFeedbackEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
GiveFeedbackEventArgs | args | Information about the event. |
IAcceptDrop.OnQueryContinueDrag(QueryContinueDragEventArgs)
Raises the QueryContinueDrag event.
Declaration
void IAcceptDrop.OnQueryContinueDrag(QueryContinueDragEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
QueryContinueDragEventArgs | args | Information about the event. |