CoreDragDropManager Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Manages access for drag and drop within and between apps.
public ref class CoreDragDropManager sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class CoreDragDropManager final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class CoreDragDropManager
Public NotInheritable Class CoreDragDropManager
- Inheritance
- Attributes
Windows requirements
| Requirements | Description |
|---|---|
| Device family |
Windows 10 (introduced in 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced in v1.0)
|
Examples
The following example demonstrates how to use the CoreDragDropManager to set up a drag-and-drop target that filters incoming data and delegates handling to a specified control.
using System;
using Windows.ApplicationModel.DataTransfer;
using Windows.ApplicationModel.DataTransfer.DragDrop.Core;
using Windows.UI.Xaml.Controls;
public sealed partial class MainPage : Page
{
private void DropOperationTargetRequested(CoreDragDropManager sender, CoreDropOperationTargetRequestedEventArgs evtArgs)
{
// Create a target (see above for more implementation details)
var target = new DropTarget();
// Example filter: Only allow storage files
target.DragOver += (s, e) =>
{
if (e.DataView.Contains(StandardDataFormats.StorageItems))
{
e.AcceptedOperation = DataPackageOperation.Copy;
}
else
{
e.AcceptedOperation = DataPackageOperation.None;
}
};
// Delegate handling to a specified control
target.Drop += (s, e) =>
{
// Assuming 'specifiedControl' is a UI element in your app
specifiedControl.HandleDrop(e);
};
evtArgs.SetTarget(target);
}
public MainPage()
{
InitializeComponent();
var dragDropManager = CoreDragDropManager.GetForCurrentView();
dragDropManager.TargetRequested += DropOperationTargetRequested;
}
}
// Example of a specified control handling the drop
public class SpecifiedControl : UserControl
{
public void HandleDrop(CoreDragInfo dragInfo)
{
// Handle the drop operation here
}
}
Properties
| Name | Description |
|---|---|
| AreConcurrentOperationsEnabled |
Gets or sets whether concurrent drag and drop operations are enabled. |
Methods
| Name | Description |
|---|---|
| GetForCurrentView() |
Gets the core drag and drop manager associated with the currently visible application window. |
Events
| Name | Description |
|---|---|
| TargetRequested |
Occurs when a drag and drop target is requested. |