How do I retrieve data from a DataObject ?

Platform: WPF|Category: Drag and Drop

Data from a Dataobject can be retrieved using the overloads of ‘GetDataPresent()’ method in the DataObject.

The following overloads can be used to retrieve the data from a DataObject.

  • GetDataPresent (DataFormat) – It first checks whether the data of the specified format is available. If so, it retrieves the data using the ‘GetData(DataFormat)’ method.
[C#]

dataobject.GetDataPresent(DataFormats.UnicodeText);
  • GetDataPresent (DataFormat, auto-conversion) – It first checks whether the data of the specified format is available. If so, it retrieves the data using the ‘GetData(DataFormat)’ method. It also filters the auto-convertible data in the DataObject.
[C#]

dataobject.GetDataPresent(DataFormats.UnicodeText,false);