This topic has not yet been rated - Rate this topic

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.

  Name Description
Public method DataObject() Initializes a new instance of the DataObject class.
Public method DataObject(Object) Initializes a new instance of the DataObject class that contains the specified data.
Public method DataObject(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 method DataObject(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 method DataObject(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
  Name Description
Public method Static member AddCopyingHandler Adds a Copying event handler to a specified dependency object.
Public method Static member AddPastingHandler Adds a Pasting event handler to a specified dependency object.
Public method Static member AddSettingDataHandler Adds a SettingData event handler to a specified dependency object.
Public method ContainsAudio Queries a data object for the presence of data in the WaveAudio data format.
Public method ContainsFileDropList Queries a data object for the presence of data in the FileDrop data format.
Public method ContainsImage Queries a data object for the presence of data in the Bitmap data format.
Public method ContainsText() Queries a data object for the presence of data in the UnicodeText format.
Public method ContainsText(TextDataFormat) Queries a data object for the presence of data in a text data format.
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetAudioStream Returns a stream that contains data in the WaveAudio data format.
Public method GetData(String) Returns data in a format specified by a string.
Public method GetData(Type) Returns a data object in a format specified by a Type object.
Public method GetData(String, Boolean) Returns a data object in a specified format, optionally converting the data to the specified format.
Public method GetDataPresent(String) Determines whether the data is available in, or can be converted to, a format specified by a string.
Public method GetDataPresent(Type) Determines whether the data is available in, or can be converted to, a format specified by a Type object.
Public method GetDataPresent(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 method GetFileDropList Returns a string collection that contains a list of dropped files.
Public method GetFormats() Returns a list of formats in which the data in this data object is stored, or can be converted to.
Public method GetFormats(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 method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetImage Returns a BitmapSource object that contains data in the Bitmap format.
Public method GetText() Returns a string that contains the UnicodeText data in this data object.
Public method GetText(TextDataFormat) Returns a string that contains text data of the specified format in this data object.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Static member RemoveCopyingHandler Removes a Copying event handler from a specified dependency object.
Public method Static member RemovePastingHandler Removes a Pasting event handler from a specified dependency object.
Public method Static member RemoveSettingDataHandler Removes a SettingData event handler from a specified dependency object.
Public method SetAudio(Byte[]) Stores audio data (WaveAudio data format) in this data object. The audio data is specified as a byte array.
Public method SetAudio(Stream) Stores audio data (WaveAudio data format) in this data object. The audio data is specified as a stream.
Public method SetData(Object) Stores the specified data in this data object, automatically determining the data format from the source object type.
Public method SetData(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 method SetData(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 method SetData(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 method SetFileDropList Stores FileDrop data in this data object. The dropped file list is specified as a string collection.
Public method SetImage Stores Bitmap data in this data object. The image data is specified as a BitmapSource.
Public method SetText(String) Stores UnicodeText data, specified as a string, in this data object.
Public method SetText(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 method ToString Returns a string that represents the current object. (Inherited from Object.)
Top
  Name Description
Public attached event Copying Occurs 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 event Pasting Occurs when the associated dependency object is ready to paste data.
Public attached event SettingData Occurs when the associated dependency object attempts to add a new data format to a DataObject.
Top
  Name Description
Public field Static member CopyingEvent Identifies the Copying attached event.
Public field Static member PastingEvent Identifies the Pasting attached event.
Public field Static member SettingDataEvent Identifies the SettingData attached event.
Top
  Name Description
Explicit interface implemetation Private method IDataObject.DAdvise Creates 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 implemetation Private method IDataObject.DUnadvise Destroys a notification connection that had been previously established.
Explicit interface implemetation Private method IDataObject.EnumDAdvise Creates an object that can be used to enumerate the current advisory connections.
Explicit interface implemetation Private method IDataObject.EnumFormatEtc Creates an object for enumerating the FORMATETC structures for a data object. These structures are used in calls to GetData or SetData.
Explicit interface implemetation Private method IDataObject.GetCanonicalFormatEtc Provides 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 implemetation Private method IDataObject.GetData Obtains 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 implemetation Private method IDataObject.GetDataHere Obtains 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 implemetation Private method IDataObject.QueryGetData Determines 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 implemetation Private method IDataObject.SetData Transfers 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, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ