Export (0) Print
Expand All

DataObject Class

Provides a basic implementation of the IDataObject interface, which defines a format-independent mechanism for transferring data.

System.Object
  System.Windows.DataObject

Namespace:  System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public sealed class DataObject : IDataObject, 
	IDataObject

The DataObject type exposes the following members.

  NameDescription
Public methodDataObject()Initializes a new instance of the DataObject class.
Public methodDataObject(Object)Initializes a new instance of the DataObject class that contains the specified data.
Public methodDataObject(String, Object)Initializes a new instance of the DataObject class that contains the specified data and its associated format; the format is specified by a string.
Public methodDataObject(Type, Object)Initializes a new instance of the DataObject class that contains the specified data and its associated format; the data format is specified by a Type object.
Public methodDataObject(String, Object, Boolean)Initializes a new instance of the DataObject class that contains the specified data and its associated format; the format is specified by a string. This overload includes a Boolean flag to indicate whether the data may be converted to another format on retrieval.
Top

  NameDescription
Public methodStatic memberAddCopyingHandlerAdds a Copying event handler to a specified dependency object.
Public methodStatic memberAddPastingHandlerAdds a Pasting event handler to a specified dependency object.
Public methodStatic memberAddSettingDataHandlerAdds a SettingData event handler to a specified dependency object.
Public methodContainsAudioQueries a data object for the presence of data in the WaveAudio data format.
Public methodContainsFileDropListQueries a data object for the presence of data in the FileDrop data format.
Public methodContainsImageQueries a data object for the presence of data in the Bitmap data format.
Public methodContainsText()Queries a data object for the presence of data in the UnicodeText format.
Public methodContainsText(TextDataFormat)Queries a data object for the presence of data in a text data format.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetAudioStreamReturns a stream that contains data in the WaveAudio data format.
Public methodGetData(String)Returns data in a format specified by a string.
Public methodGetData(Type)Returns a data object in a format specified by a Type object.
Public methodGetData(String, Boolean)Returns a data object in a specified format, optionally converting the data to the specified format.
Public methodGetDataPresent(String)Determines whether the data is available in, or can be converted to, a format specified by a string.
Public methodGetDataPresent(Type)Determines whether the data is available in, or can be converted to, a format specified by a Type object.
Public methodGetDataPresent(String, Boolean)Determines whether the data is available in, or can be converted to, a specified format. A Boolean flag indicates whether to check if the data can be converted to the specified format if it is not available in that format.
Public methodGetFileDropListReturns a string collection that contains a list of dropped files.
Public methodGetFormats()Returns a list of formats in which the data in this data object is stored, or can be converted to.
Public methodGetFormats(Boolean)Returns a list of formats in which the data in this data object is stored. A Boolean flag indicates whether to also include formats that the data can be automatically converted to.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetImageReturns a BitmapSource object that contains data in the Bitmap format.
Public methodGetText()Returns a string that contains the UnicodeText data in this data object.
Public methodGetText(TextDataFormat)Returns a string that contains text data of the specified format in this data object.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodStatic memberRemoveCopyingHandlerRemoves a Copying event handler from a specified dependency object.
Public methodStatic memberRemovePastingHandlerRemoves a Pasting event handler from a specified dependency object.
Public methodStatic memberRemoveSettingDataHandlerRemoves a SettingData event handler from a specified dependency object.
Public methodSetAudio(Byte[])Stores audio data (WaveAudio data format) in this data object. The audio data is specified as a byte array.
Public methodSetAudio(Stream)Stores audio data (WaveAudio data format) in this data object. The audio data is specified as a stream.
Public methodSetData(Object)Stores the specified data in this data object, automatically determining the data format from the source object type.
Public methodSetData(String, Object)Stores the specified data in this data object, along with one or more specified data formats; the data format is specified by a string.
Public methodSetData(Type, Object)Stores the specified data in this data object, along with one or more specified data formats; the data format is specified by a Type object.
Public methodSetData(String, Object, Boolean)Stores the specified data in this data object, along with one or more specified data formats. This overload includes a Boolean flag to indicate whether the data can be converted to another format on retrieval.
Public methodSetFileDropListStores FileDrop data in this data object. The dropped file list is specified as a string collection.
Public methodSetImageStores Bitmap data in this data object. The image data is specified as a BitmapSource.
Public methodSetText(String)Stores UnicodeText data, specified as a string, in this data object.
Public methodSetText(String, TextDataFormat)Stores text data in this data object. The format of the text data to store is specified with a member of TextDataFormat.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public attached eventCopyingOccurs when the associated dependency object has prepared appropriate data formats that represent the copy selection, added the copy selection formats to a DataObject, and is ready to either place the DataObject on the Clipboard or begin a drag-and-drop operation.
Public attached eventPastingOccurs when the associated dependency object is ready to paste data.
Public attached eventSettingDataOccurs when the associated dependency object attempts to add a new data format to a DataObject.
Top

  NameDescription
Public fieldStatic memberCopyingEventIdentifies the Copying attached event.
Public fieldStatic memberPastingEventIdentifies the Pasting attached event.
Public fieldStatic memberSettingDataEventIdentifies the SettingData attached event.
Top

  NameDescription
Explicit interface implemetationPrivate methodIDataObject.DAdviseCreates a connection between a data object and an advisory sink. This method is called by an object that supports an advisory sink and enables the advisory sink to be notified of changes in the object's data.
Explicit interface implemetationPrivate methodIDataObject.DUnadviseDestroys a notification connection that had been previously established.
Explicit interface implemetationPrivate methodIDataObject.EnumDAdviseCreates an object that can be used to enumerate the current advisory connections.
Explicit interface implemetationPrivate methodIDataObject.EnumFormatEtcCreates an object for enumerating the FORMATETC structures for a data object. These structures are used in calls to GetData or SetData.
Explicit interface implemetationPrivate methodIDataObject.GetCanonicalFormatEtcProvides a standard FORMATETC structure that is logically equivalent to a more complex structure. Use this method to determine whether two different FORMATETC structures would return the same data, removing the need for duplicate rendering.
Explicit interface implemetationPrivate methodIDataObject.GetDataObtains data from a source data object. The GetData method, which is called by a data consumer, renders the data described in the specified FORMATETC structure and transfers it through the specified STGMEDIUM structure. The caller then assumes responsibility for releasing the STGMEDIUM structure.
Explicit interface implemetationPrivate methodIDataObject.GetDataHereObtains data from a source data object. This method, which is called by a data consumer, differs from the GetData method in that the caller must allocate and free the specified storage medium.
Explicit interface implemetationPrivate methodIDataObject.QueryGetDataDetermines whether the data object is capable of rendering the data described in the FORMATETC structure. Objects attempting a paste or drop operation can call this method before calling GetData to get an indication of whether the operation may be successful.
Explicit interface implemetationPrivate methodIDataObject.SetDataTransfers data to the object that implements this method. This method is called by an object that contains a data source.
Top

The following example shows how to use this class.

string stringData = "Some string data to store...";
string dataFormat = DataFormats.UnicodeText;
DataObject dataObject = new DataObject(dataFormat, stringData);

.NET Framework

Supported in: 4.6, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft