Interface IClipboard
[NotClientImplementable]
public interface IClipboard
Methods
ClearAsync()
Clears any data from the system Clipboard.
Task ClearAsync()
Returns
FlushAsync()
Permanently adds the data that is on the Clipboard so that it is available after the data's original application closes.
Task FlushAsync()
Returns
Remarks
This method works only on Windows platform, on other platforms it does nothing.
GetDataAsync(string)
Retrieves data in a specified format from the Clipboard.
Task<object?> GetDataAsync(string format)
Parameters
format
stringA string that specifies the format of the data to retrieve. For a set of predefined data formats, see the DataFormats class.
Returns
GetFormatsAsync()
Get list of available Clipboard format.
Task<string[]> GetFormatsAsync()
Returns
GetTextAsync()
Returns a string containing the text data on the Clipboard.
Task<string?> GetTextAsync()
Returns
- Task<string>
A string containing text data in the specified data format, or an empty string if no corresponding text data is available.
SetDataObjectAsync(IDataObject)
Places a specified non-persistent data object on the system Clipboard.
Task SetDataObjectAsync(IDataObject data)
Parameters
data
IDataObjectA data object (an object that implements IDataObject) to place on the system Clipboard.
Returns
Exceptions
- ArgumentNullException
data
is null.
SetTextAsync(string?)
Stores text data on the Clipboard. The text data to store is specified as a string.
Task SetTextAsync(string? text)
Parameters
text
stringA string that contains the UnicodeText data to store on the Clipboard.
Returns
Exceptions
- ArgumentNullException
text
is null.
TryGetInProcessDataObjectAsync()
If clipboard contains the IDataObject that was set by a previous call to SetDataObjectAsync(IDataObject), return said IDataObject instance. Otherwise, return null. Note that not every platform supports that method, on unsupported platforms this method will always return null
Task<IDataObject?> TryGetInProcessDataObjectAsync()