DragEventArgs.Data Property

Gets a data object (implements IDataObject) that contains the data associated with the corresponding drag event. This value is not useful in all event cases; see Remarks.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public ReadOnly Property Data As IDataObject
public IDataObject Data { get; }

Property Value

Type: System.Windows.IDataObject
The data object that contains the data that is associated with the corresponding drag event.

Remarks

The data that is contained in a DragEventArgs instance is useful only when the event that generated the data is Drop. For other events that also use DragEventArgs (DragEnter, DragLeave, DragOver), the value of Data is not null. However, any attempt to call the IDataObject API on that object always raises a SecurityException. This ensures that only the drop target is permitted access to the data.

The Silverlight implementation of IDataObject is symmetrical with the WPF implementation in terms of API surface. However, the only scenario that is enabled by the returned data object in Data is file drop. Therefore, these IDataObject APIs are not enabled on the returned data object:

  • Any API call that uses a String-typed format parameter must specify the string equivalent to the constant DataFormats.FileDrop.

  • Type-typed format parameter APIs are not supported.

  • APIs that support automatic format conversion are not supported.

  • The data object is read-only to callers. Therefore, all signatures of SetData are not supported.

For more information about accessing data from a data object, see GetData(String).

Silverlight file drop does not support dropping a directory. However, it does support selecting and then dropping multiple files. In this case, the Data contains a data payload that is in the FileDrop format. You might need to parse or process this format as an enumeration or array, depending on your specific scenario and requirements.

Version Information

Silverlight

Supported in: 5, 4

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.